10
I created a function that generates random objects in the area canvas
and wanted that after the end of this function the area was clean.
Is there any possibility of doing that?
10
I created a function that generates random objects in the area canvas
and wanted that after the end of this function the area was clean.
Is there any possibility of doing that?
10
Try it like this:
context.clearRect(0, 0, canvas.width, canvas.height);
Reference:
2
context.clearRect(A, B, C, D);
A: point on the x-axis where cleaning will start.
B: point on the y-axis where cleaning will start.
C: Limit on X-axis to be cleaned.
D: Limit on the y-axis to be cleaned.
context.clearRect(0, 0, canvas.width, canvas.height);
Note: This way you will clean from the point X = 0 and Y = 0, until the end of your canvas
, that is canvas.width
and canvas.height
.
Browser other questions tagged javascript canvas
You are not signed in. Login or sign up in order to post.
Thank you @Gabriel! [OFF TOPIC] You know if there is a possibility to add events to my elements within the canvas?
– Odair
@Odair Take a look at this article at the bottom of the page: http://diveintohtml5.com.br/canvas.html. Here’s how to play a little game with canvas by adding events, etc.
– user622
Valeu @Gabriel!
– Odair