D
D
Dmitriy G2020-07-16 13:12:57
JavaScript
Dmitriy G, 2020-07-16 13:12:57

How to make canvas loop?

You need to complete the following point:
the movement of the logo should be cyclic - if the logo goes beyond the canvas, then the disappeared part should appear on the opposite side.
5f1027a526980998870678.jpeg
5f1028204196b703126449.jpeg
how to do it?
Logo and movement code
Video as it should be

Answer the question

In order to leave comments, you need to log in

3 answer(s)
R
RAX7, 2020-07-16
@Dimgol

Draw a logo inside the pattern and set the transformation for the pattern for animation.

https://developer.mozilla.org/en-US/docs/Web/API/C...

K
Karpion, 2020-07-16
@Karpion

How exactly is the logo drawn?
You can stupidly do this:

  1. bring the coordinates of the logo to the form where the upper left corner of the logo is in the canvas area - by adding or subtracting the size of the canvas;
  2. draw the logo four times: in the right place, to the left by the size of the canvas, above by the size of the canvas, and to the left-below by the size of the canvas (the size of the canvas is taken at the corresponding coordinate).
Did I explain clearly?
PS: You can check the need to draw additional copies of the logo.

E
Elvis, 2020-07-16
@Dr_Elvis

here I see 2 options
1) you track when the coordinates go beyond the visible field, you have it 0 and 400, and redraw on several objects, since you no longer have 3 sticks, but 2 on one side and 1-2 on the other
2) but it's easier to multiply your shape in X and Y at a distance of 400 pixels from the edges. then when moving beyond the borders on the other side, another, exactly the same figure will appear, which will give the desired effect.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question