File tree Expand file tree Collapse file tree 1 file changed +19
-18
lines changed
Expand file tree Collapse file tree 1 file changed +19
-18
lines changed Original file line number Diff line number Diff line change 1- // We're making 20 flowers
1+ // We're making 40 flowers
22// each is made of 240 pretty points
3+ var colors = [
4+ 'tomato' ,
5+ 'lightsalmon' ,
6+ 'plum' ,
7+ 'mediumslateblue'
8+ ] ;
9+
310var resolution = 240 ;
411var radius = 200 ;
5- var two ;
6-
7- for ( var k = 2 , i = 0 ; k < 41 ; k ++ ) {
8- $ ( 'body' ) . append ( '<div class="canvas" id="twocanvas' + i + '"></div>' ) ;
9- // Setup the canvas
10- var two = new Two ( {
11- autostart : true
12- } ) . appendTo ( document . getElementById ( 'twocanvas' + i ) ) ;
13- i ++ ;
14-
12+ var shapes = [ ] ;
13+ // Make the flowers
14+ for ( var k = 2 ; k < 44 ; k ++ ) {
1515 var points = [ ] ;
1616 for ( var j = 0 ; j < resolution ; j ++ ) {
1717 points [ j ] = new Two . Anchor ( ) ;
1818 roseMath ( points [ j ] , k , Math . PI * 2 * j / resolution ) ;
1919 }
2020 // Create shape
21- var shape = two . makeCurve ( points ) ;
22- // Center Shape to div
23- two . scene . translation . set ( two . width / 2 , two . height / 2 ) ;
21+ var shape = new Two . Path ( points , true , true ) ;
22+
2423 // Style the shape
25- shape . fill = 'rgb(0, 0, 0)' ;
26- shape . stroke = 'rgb(255, 255, 255)' ;
27- shape . linewidth = 6 ;
28- two . update ( ) ;
24+ var color = colors [ Math . floor ( Math . random ( ) * colors . length ) ] ;
25+ shape . stroke = color ;
26+ shape . noFill ( ) ;
27+ shape . rotation = Math . floor ( Math . random ( ) * 4 ) * Math . PI / 2 + Math . PI / 4 ;
28+ shapes . push ( shape ) ;
2929}
30+ // two.add(group)
3031
3132function roseMath ( v , k , t ) {
3233 v . x = radius * Math . cos ( k * t ) * Math . cos ( t ) ;
You can’t perform that action at this time.
0 commit comments