How to clean a canvas area?

9

I created a function that is generating random objects in the canvas area and wanted to clear the area after the function was finished.

Is there any way to do this?

    
asked by anonymous 17.02.2014 / 06:51

2 answers

8

Try this:

context.clearRect(0, 0, canvas.width, canvas.height);

Reference:

17.02.2014 / 07:26
2
context.clearRect(A, B, C, D);

A: point on the X axis where cleaning will start.

B: point on the Y axis where the cleaning will begin.

C: X-axis boundary to where it will be cleaned.

D: Limit on the Y axis to where it will be cleaned.

context.clearRect(0, 0, canvas.width, canvas.height);

Note: this clears the form u from the point X = 0 and Y = 0 until the end of its canvas % which is canvas.width % canvas.height and

.     
10.10.2014 / 16:05