@@ -156,28 +156,28 @@ function wafflePoints(i1, i2, columns) {
156156 if ( i2 < i1 ) {
157157 return wafflePoints ( i2 , i1 , columns ) ;
158158 }
159- return [
160- [ 0 , Math . ceil ( i1 / columns ) ] ,
161- [ Math . floor ( i1 % columns ) , Math . ceil ( i1 / columns ) ] ,
162- [ Math . floor ( i1 % columns ) , Math . floor ( i1 / columns ) + ( i1 % 1 ) ] ,
163- [ Math . ceil ( i1 % columns ) , Math . floor ( i1 / columns ) + ( i1 % 1 ) ] ,
164- ... ( i1 % columns > columns - 1
165- ? [ ]
166- : [
167- [ Math . ceil ( i1 % columns ) , Math . floor ( i1 / columns ) ] ,
168- [ columns , Math . floor ( i1 / columns ) ]
169- ] ) ,
170- [ columns , Math . floor ( i2 / columns ) ] ,
171- [ Math . ceil ( i2 % columns ) , Math . floor ( i2 / columns ) ] ,
172- [ Math . ceil ( i2 % columns ) , Math . floor ( i2 / columns ) + ( i2 % 1 ) ] ,
173- [ Math . floor ( i2 % columns ) , Math . floor ( i2 / columns ) + ( i2 % 1 ) ] ,
174- ... ( i2 % columns < 1
175- ? [ ]
176- : [
177- [ Math . floor ( i2 % columns ) , Math . ceil ( i2 / columns ) ] ,
178- [ 0 , Math . ceil ( i2 / columns ) ]
179- ] )
180- ] ;
159+ const x1f = Math . floor ( i1 % columns ) ;
160+ const x1c = Math . ceil ( i1 % columns ) ;
161+ const x2f = Math . floor ( i2 % columns ) ;
162+ const x2c = Math . ceil ( i2 % columns ) ;
163+ const y1f = Math . floor ( i1 / columns ) ;
164+ const y1c = Math . ceil ( i1 / columns ) ;
165+ const y2f = Math . floor ( i2 / columns ) ;
166+ const y2c = Math . ceil ( i2 / columns ) ;
167+ const points = [ ] ;
168+ if ( y2c > y1c ) points . push ( [ 0 , y1c ] ) ;
169+ points . push ( [ x1f , y1c ] , [ x1f , y1f + ( i1 % 1 ) ] , [ x1c , y1f + ( i1 % 1 ) ] ) ;
170+ if ( ! ( i1 % columns > columns - 1 ) ) {
171+ points . push ( [ x1c , y1f ] ) ;
172+ if ( y2f > y1f ) points . push ( [ columns , y1f ] ) ;
173+ }
174+ if ( y2f > y1f ) points . push ( [ columns , y2f ] ) ;
175+ points . push ( [ x2c , y2f ] , [ x2c , y2f + ( i2 % 1 ) ] , [ x2f , y2f + ( i2 % 1 ) ] ) ;
176+ if ( ! ( i2 % columns < 1 ) ) {
177+ points . push ( [ x2f , y2c ] ) ;
178+ if ( y2c > y1c ) points . push ( [ 0 , y2c ] ) ;
179+ }
180+ return points ;
181181}
182182
183183function maybeRound ( round ) {
0 commit comments