Answer the question
In order to leave comments, you need to log in
How to understand canvas?
Hello kitties!
I deal with simple animation from textbooks:
https://jsfiddle.net/3Leh8c1t/25/
It seems that there is not enough code and there are descriptions of all methods, but I just can’t stick how they spin. Yes, and with the shadow, too, nicherta is not clear.
On line 17
This is a black fill with translucency. But I don't understand why this fill only works on a rectangle of line 26?
Why isn't the entire canvas being filled? I don't see any bindings.
The idea is to create a frame, but I do not see the difference if I comment out this line.ctx.fillStyle = 'rgba(0, 0, 0, 0.4)';
ctx.fillRect(0, -12, 50, 24); // Shadow
ctx.strokeStyle = 'rgba(0, 153, 255, 0.4)';
Who works with this, how does it happen in general? There is a color 0, 153, 255 - do I need to open a separate tab with the rgb service and manually enter these numbers? Is there any easier way to do this? Or am I going in the wrong direction at all? Debugging is also not clear, I can put a breakpoint at the beginning of the draw function. But the step-by-step launch does not show anything; after exiting the function, it immediately shows the finished result. That is, for debugging, I need to get rid of the time and pass some fixed selected value to the ctx.rotate function, manually restart the script to look frame by frame, right?
Explain with the orbits of the planets, too, please. I do not understand why the Earth revolves in its orbit, and the Moon in its own, and even around the moving Earth? I see lines:
ctx.rotate(((2 * Math.PI) / 60) * time.getSeconds() + ((2 * Math.PI) / 60000) * time.getMilliseconds());
ctx.translate(105, 0);
ctx.drawImage(earth, -12, -12);
Answer the question
In order to leave comments, you need to log in
The fillStyle property sets the style of the brush, so to speak, as in Photoshop. You select the fill color in Photoshop, and then fill it (fillRect at the specified coordinates).
Can be set with constants, such as red, blue, green, etc.
If strokeStyle or fillStyle are not set, their default value is taken, which is like white.
You need experience, just write a lot of such things, read about such things, and all this will become elementary.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question