Background repeat(x,y) animation


#1

Say I have a background that repeats x and y, is there a way to create an animation that makes it slowly move to the right and repeat infinitely?

The image is blurred, so the size is bigger than the page the keep the image edges from being white.

Background Repeat.hype.zip (1.6 MB)


(Victor) #2

do you want the code or the animation with the program.?


#3

Either way is fine really. When I tried to create the background with a blur using CSS, it made my whole document blurry.


(Victor) #4

i seeโ€ฆ the pic inside element and has some px border thats why blurs whole backgroundโ€ฆ


(Victor) #5

you mean like this ? https://davidwalsh.name/demo/background-animation-css.php


#6

It works!! but iโ€™m having a bit of trouble with the animation. It changed direction and speed with different page layouts. Got any ideas?

I used 100% 100% to make it go diagonally.

Background Repeat.hype.zip (1.5 MB)


(Jonathan Deutsch) #7

Were you trying to do something like this?

Background Repeat-2.hype.zip (1.5 MB)


(Freelancer) #8

@PappaSmalls yes this is the right method, I did the same.

In Hype, you need to move an object and sync the displacement ( A to B in loop) with a shape with a perfect tile ( vertical and horizontal ).

this is a good software to make patterns easily.
http://neatberry.com/products/patterno/

@jonathan in future an option to animate also the X/Y coordinates ( not covering CSS, only real size) would be a great improvement because you can animate complex scheme ( for example landscapes) without move an objects, also with parallax ( without code). A powerful but simple tool for cartoons and dynamic scenes.

for example, I used the method above to sync all waves but I spent a lot of time.


(Victor) #9

the issue is when it loop you se the transaction movement. is there any way to fix that ?


(David Guillermo Escalante Trinidad) #10

The problem was with the final position, it didnโ€™t matched the first one. Also, I reduced the background file size since it is blurred it doesnโ€™t need many details.

bgrepeat_fixed.hype.zip (249.3 KB)


(Jonathan Deutsch) #11

Iโ€™m not quite clear what you mean here; and unfortunately the link is a 404โ€ฆ Can you elaborate and send a new link?


#12

@jonathan The page is meant to be a 404 :slight_smile: heโ€™s referring to the wave animation he made for that page :slight_smile: I think you need more coffee :slight_smile: I think the gist is to match the object position at the start and end of the animation so that it looks seamless. Iโ€™m not sure about the mention of having x,y coords as animatable properties as I havenโ€™t been following the discussion.


(๐•„๐•š๐•”๐•™๐•’๐•–๐• ๐”พ๐•’๐•ฃ๐• ๐•—๐•’๐•๐• ) #13

You might want to see thisโ€ฆ

I had an awful time trying to create a scrolling background โ€“ especially since it had to work across multiple screen sizes. If you look at that thread, you can see the problems and solutions discussed.

The end result is hereโ€ฆ

It was extra tricky because the background uses an SVG image.

I basically scale the scene with JavaScript and I have a large element thatโ€™s twice the size of the scene. The background image is shown once and repeated once. It scrolls edge-to-edge and then repeats. I stretch the background vertically to get rid of horizontal line. (For some reason, a seam would show up. I tried to get rid of it, but then just stretched the background vertically.)


#14

@Photics Having the same issue as you here, using CSS transitions throttles everything and my mac jumps from 40Cโ€ข to 75Cโ€ข in a minute.

Iโ€™ve tried various other things and they all seem to just lag and overheat.


(Lucky) #15

would this work?
Background Repeat.hype.zip (1.5 MB)

window.requestAnimFrame = (function(){
  return  window.requestAnimationFrame       ||
          window.webkitRequestAnimationFrame ||
          window.mozRequestAnimationFrame    ||
          function( callback ){
            window.setTimeout(callback, 1000 / 60);
          };
})();
var xOffset=0,
	yOffset=0;
function bgMove(){
  	xOffset-=1;
  	yOffset-=1;
  	backgroundImage.style.backgroundPosition = xOffset+"px "+yOffset+"px";
   requestAnimFrame(bgMove);
 }
 bgMove();

I would strongly not recommend using css effects on such a massive image, i would do the blur in photoshop and export the image out already blurred. Pretty sure the lag is both because of the effects and the fact the image is so big.


#16

This is much better! Thanks for the code.

The document I provided was just an example. Luckily my image is much smaller, but Iโ€™ll definitely pre-blur it.


(๐•„๐•š๐•”๐•™๐•’๐•–๐• ๐”พ๐•’๐•ฃ๐• ๐•—๐•’๐•๐• ) #17

I fixed the overheating problem by manually scaling the scene. This dramatically reduced the strain on the CPU. Itโ€™s not constant animation, so it works.

Regular Hype animations seem to work for me. With B.R.O.O.M., I have a full screen SVG moving across the screen. The CPU seems OK. I think the problem is when I use the โ€œScale behaviorโ€, which severely hinders performance. I told Tumult about this issue, so hopefully it will be fixed in a future version.