Skip to content

Commit 4da2660

Browse files
committed
Use StackOverflow recommended approach to clearing canvas
1 parent a468129 commit 4da2660

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

js/lesson6/tutorial.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,10 +72,10 @@ context.strokeRect(300, 100, 50, 100);
7272

7373
### Reseting canvas
7474

75-
Canvas does not have a reset function, but you can reset it by setting its width. You don't even need to change the value of the width so you can do:
75+
Canvas does not have a reset function, but there is a function to clear a specified rectangle called `context.clearRect`. You can use it like so:
7676

7777
```javascript
78-
canvas.width = canvas.width;
78+
context.clearRect(0, 0, canvas.width, canvas.height);
7979
```
8080

8181
**Exercise**

0 commit comments

Comments
 (0)