File tree Expand file tree Collapse file tree 1 file changed +35
-0
lines changed
Expand file tree Collapse file tree 1 file changed +35
-0
lines changed Original file line number Diff line number Diff line change 1+ // We're making 20 flowers
2+ // each is made of 240 pretty points
3+ var resolution = 240 ;
4+ var 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+
15+ var points = [ ] ;
16+ for ( var j = 0 ; j < resolution ; j ++ ) {
17+ points [ j ] = new Two . Anchor ( ) ;
18+ roseMath ( points [ j ] , k , Math . PI * 2 * j / resolution ) ;
19+ }
20+ // Create shape
21+ var shape = two . makeCurve ( points ) ;
22+ // Center Shape to div
23+ two . scene . translation . set ( two . width / 2 , two . height / 2 ) ;
24+ // Style the shape
25+ shape . fill = 'rgb(0, 0, 0)' ;
26+ shape . stroke = 'rgb(255, 255, 255)' ;
27+ shape . linewidth = 6 ;
28+ two . update ( ) ;
29+ }
30+
31+ function roseMath ( v , k , t ) {
32+ v . x = radius * Math . cos ( k * t ) * Math . cos ( t ) ;
33+ v . y = radius * Math . cos ( k * t ) * Math . sin ( t ) ;
34+ return v ;
35+ }
You can’t perform that action at this time.
0 commit comments