Skip to content

Commit 904a143

Browse files
Merge pull request #353 from marten/update-js-canvas-tutorial
Update JS canvas tutorial
2 parents 7a3df40 + ee7c833 commit 904a143

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

js/lesson6/tutorial.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,22 +65,22 @@ context.fillRect(100, 100, 50, 100);
6565
Now let's add another rectangle, but this time only its outline.
6666

6767
```
68-
context.strokeRect(400, 100, 50, 100);
68+
context.strokeRect(300, 100, 50, 100);
6969
```
7070

7171
**Bonus** Add a new rectangle outline with dimensions **120x150** at the bottom right of the screen. The **line width** of the rectangle should be 1.
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**
8282

83-
Reset the canvas when the Reset button is clicked, by calling a reset() function.
83+
Reset the canvas when the Reset button is clicked, by calling the `reset()` function.
8484

8585
### Drawing paths
8686

0 commit comments

Comments
 (0)