File tree 1 file changed +30
-9
lines changed
08 - Fun with HTML5 Canvas
1 file changed +30
-9
lines changed Original file line number Diff line number Diff line change 1
1
<!DOCTYPE html>
2
2
< html lang ="en ">
3
+
3
4
< head >
4
5
< meta charset ="UTF-8 ">
5
6
< title > HTML5 Canvas</ title >
6
7
</ head >
8
+
7
9
< body >
8
- < canvas id ="draw " width ="800 " height ="800 "> </ canvas >
9
- < script >
10
- </ script >
10
+ < canvas id ="draw " width ="800 " height ="800 "> </ canvas >
11
+ < script >
12
+ const canvas = document . querySelector ( '#draw' ) ;
13
+ const ctx = canvas . getContext ( '2d' ) ;
14
+
15
+ canvas . width = window . innerWidth ;
16
+ canvas . height = window . innerHeight ;
17
+ ctx . strokeStyle = '#BADA55' ;
18
+ ctx . lineCap = 'round' ;
19
+
20
+ let isDrawing = false ;
21
+ let lastX = 0 ;
22
+ let lastY = 0 ;
11
23
12
- < style >
13
- html , body {
14
- margin : 0 ;
15
- }
16
- </ style >
24
+ function draw ( e ) {
25
+ console . log ( 'e' , e ) ;
26
+ }
27
+
28
+ canvas . addEventListener ( 'mousemove' , draw ) ;
29
+ </ script >
30
+
31
+ < style >
32
+ html ,
33
+ body {
34
+ margin : 0 ;
35
+ }
36
+ </ style >
17
37
18
38
</ body >
19
- </ html >
39
+
40
+ </ html >
You can’t perform that action at this time.
0 commit comments