File tree Expand file tree Collapse file tree 2 files changed +37
-12
lines changed Expand file tree Collapse file tree 2 files changed +37
-12
lines changed Original file line number Diff line number Diff line change 77 < script src ="libs/jquery-2.2.1.min.js "> </ script >
88 < script src ="script.js "> </ script >
99 < script src ="libs/quicksettings.min.js "> </ script >
10+ < script src ="libs/particle.js "> </ script >
1011 < link rel ="stylesheet " type ="text/css " href ="styles.css ">
1112 </ head >
1213 < body >
1314 < h1 >
1415 Physical Computing for Web Devs
1516 </ h1 >
17+
18+ < canvas > </ canvas >
1619 </ body >
1720
1821</ html >
Original file line number Diff line number Diff line change @@ -5,20 +5,42 @@ var board = new five.Board({
55 port : "/dev/ttyUSB0"
66} ) ;
77
8- board . on ( "ready" , function ( ) {
9- console . log ( "I can see the board!" ) ;
8+ var particles = [ ] ;
109
11- var pin = 13 ;
10+ window . addEventListener ( "DOMContentLoaded" , function ( ) {
11+ var canvas = document . getElementsByTagName ( "canvas" ) [ 0 ] ;
12+ var context = canvas . getContext ( "2d" ) ;
1213
13- var led = new five . Led ( ) ;
14- led . on ( ) ;
14+ canvas . width = window . innerWidth ;
15+ canvas . height = window . innerHeight ;
1516
16- var proximity = new five . Proximity ( {
17- controller : "2Y0A21" ,
18- pin : "A0"
19- } ) ;
17+ board . on ( "ready" , function ( ) {
18+ console . log ( "I can see the board!" ) ;
19+
20+ var led = new five . Led ( ) ;
21+ led . on ( ) ;
22+
23+ var proximity = new five . Proximity ( {
24+ controller : "2Y0A21" ,
25+ pin : "A0"
26+ } ) ;
27+
28+ proximity . within ( [ 8 , 65 ] , "cm" , function ( ) {
29+ console . log ( this . cm ) ;
2030
21- proximity . within ( [ 8 , 65 ] , "cm" , function ( ) {
22- console . log ( this . cm ) ;
31+ for ( var i = 0 ; i < 5 ; i ++ ) {
32+ var particle = new Particle ( {
33+ x : canvas . width / 2 ,
34+ y : canvas . height / 2 ,
35+ radius : 5 ,
36+ speed : 10 ,
37+ color : "#ffffff"
38+ } ) ;
39+
40+ particles . push ( particle ) ;
41+ }
42+ } ) ;
2343 } ) ;
24- } ) ;
44+ Particle . startRendering ( context , particles ) ;
45+ } ) ;
46+
You can’t perform that action at this time.
0 commit comments