@@ -77,28 +77,19 @@ function makeFlowers() {
7777 }
7878 return flowers ;
7979}
80- var f = 0 ;
80+
8181function pickFlower ( flowers ) {
82- // var f = Math.floor(Math.random() * flowers.length);
83- if ( f == flowers . length ) {
84- f = 0 ;
85- }
86- if ( typeof flowers [ f ] === 'undefined' ) {
87- f ++ ;
88- }
82+ var f = Math . floor ( Math . random ( ) * flowers . length ) ;
8983 var flower = flowers [ f ] . clone ( ) ;
90- f ++ ;
91- // Style the shape
92- // var colors = ['tomato', 'lightsalmon', 'floralwhite', 'orangered',
93- // 'gold', 'red', 'darkorange'];
94- // var color = colors[Math.floor(Math.random() * colors.length)];
95- // flower.stroke = color;
96- // flower.fill = color;
84+ var colors = [ 'tomato' , 'orangered' , 'floralwhite' ,
85+ 'gold' , 'red' , 'darkorange' ] ;
86+ colors = [ 'DARKMAGENTA' , 'REBECCAPURPLE' , 'SLATEBLUE' , 'ROYALBLUE' , '#9c27b0' , '#9f9fff' ,
87+ 'ALICEBLUE' , 'PLUM' , 'CORNFLOWERBLUE' , 'DARKBLUE' , 'MEDIUMBLUE' , 'DARKSLATEBLUE' ] ;
88+ var color = colors [ Math . floor ( Math . random ( ) * colors . length ) ] ;
89+ flower . rotation = ( Math . PI / 2 ) * ( Math . floor ( Math . random ( ) * 12 ) / 12 ) ;
90+ flower . stroke = color ;
91+ flower . fill = color ;
9792 flower . linewidth = 4 ;
9893 flower . cap = 'round' ;
99- // flower.rotation = Math.floor(Math.random() * 4) * Math.PI / 2 + Math.PI / 4;
100- // For animation later on
101- // flower.step = (Math.floor(Math.random() * 8) / 8) * Math.PI / 60;
102- // flower.step *= Math.random() > 0.5 ? - 1 : 1;
10394 return flower ;
10495}
0 commit comments