@@ -21,11 +21,6 @@ function setup() {
2121 padding = 40 ;
2222 }
2323
24- if ( isMobile && ! isOtherMediaQuery ) {
25- radius = Math . floor ( height / ( rows + 2 ) ) ;
26- }
27-
28- makeGrid ( rows , cols ) ;
2924 var rows = Math . floor ( height / svgSize ) ;
3025 var cols = Math . floor ( width / svgSize ) ;
3126 var radius = Math . floor ( Math . max ( width , height ) / Math . max ( rows , cols ) ) / 2 ;
@@ -37,6 +32,15 @@ function setup() {
3732}
3833
3934function addSvgs ( size , rows , cols ) {
35+ $ ( 'body' ) . empty ( ) ;
36+ for ( var r = 0 ; r < rows ; r ++ ) {
37+ for ( var c = 0 ; c < cols ; c ++ ) {
38+ var cellId = "cell" + ( ( r * cols ) + c ) ;
39+ var cell = $ ( "<div/>" ) . addClass ( "cell" ) . attr ( "id" , cellId ) . appendTo ( 'body' ) ;
40+ $ ( cell ) . css ( { display : "inline-block" } ) ;
41+ }
42+ }
43+
4044 $ ( ".cell" ) . each ( function ( i , o ) {
4145 var two = new Two ( {
4246 width : size ,
@@ -49,27 +53,20 @@ function addSvgs(size, rows, cols) {
4953 } ) ;
5054}
5155
52- function offsetEvenRows ( size ) {
53- $ ( ".row" ) . each ( function ( index , object ) {
54- if ( index % 2 ) {
55- $ ( object ) . css ( "position" , "relative" ) ;
56- $ ( object ) . css ( "left" , size / 2 * - 1 + "px" ) ;
56+ function positionCells ( cols , size ) {
57+ $ ( ".cell" ) . each ( function ( i , o ) {
58+ var r = Math . floor ( i / cols ) ;
59+ var c = i % cols ;
60+ var top = size * r ;
61+ var left = size * c ;
62+ // Offset odd rows
63+ if ( r % 2 ) {
64+ left -= ( size / 2 ) ;
5765 }
66+ $ ( this ) . css ( { top : top , left : left , position :'absolute' } ) ;
5867 } ) ;
5968}
6069
61- function makeGrid ( rows , cols ) {
62- $ ( 'body' ) . empty ( ) ;
63- for ( var r = 0 ; r < rows ; r ++ ) {
64- var rowId = "row" + r ;
65- var row = $ ( "<div/>" ) . addClass ( "row" ) . attr ( "id" , rowId ) . appendTo ( 'body' ) ;
66- for ( var c = 0 ; c < cols + 1 ; c ++ ) {
67- var cellId = "cell" + ( ( r * rows ) + c ) ;
68- $ ( row ) . append ( '<div class="cell" id="' + cellId + '"></div>' ) ;
69- }
70- }
71- }
72-
7370function roseMath ( radius , v , k , t ) {
7471 v . x = radius * Math . cos ( k * t ) * Math . cos ( t ) ;
7572 v . y = radius * Math . cos ( k * t ) * Math . sin ( t ) ;
0 commit comments