File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1- var PerimeterPoint = require ( '../geom/rectangle/PerimeterPoint' ) ;
1+ var MarchingAnts = require ( '../geom/rectangle/MarchingAnts' ) ;
2+ var RotateLeft = require ( '../utils/array/RotateLeft' ) ;
3+ var RotateRight = require ( '../utils/array/RotateRight' ) ;
24
3- var PlaceOnRectangle = function ( items , rect )
5+ // Place the items in the array around the perimeter of the given rectangle.
6+
7+ // Placement starts from the top-left of the rectangle, and proceeds in a
8+ // clockwise direction. If the shift parameter is given you can offset where
9+ // placement begins.
10+
11+ var PlaceOnRectangle = function ( items , rect , shift )
412{
5- var angle = 0 ;
6- var step = 360 / items . length ;
13+ if ( shift === undefined ) { shift = 0 ; }
714
8- for ( var i = 0 ; i < items . length ; i ++ )
15+ var points = MarchingAnts ( rect , false , items . length ) ;
16+
17+ if ( shift > 0 )
918 {
10- PerimeterPoint ( rect , angle , items [ i ] ) ;
19+ RotateLeft ( points , shift ) ;
20+ }
21+ else if ( shift < 0 )
22+ {
23+ RotateRight ( points , Math . abs ( shift ) ) ;
24+ }
1125
12- angle += step ;
26+ for ( var i = 0 ; i < items . length ; i ++ )
27+ {
28+ items [ i ] . x = points [ i ] . x ;
29+ items [ i ] . y = points [ i ] . y ;
1330 }
1431
1532 return items ;
Original file line number Diff line number Diff line change 11var CHECKSUM = {
2- build : '2bdd4310-14b0 -11e7-829e-c915fb3f8068 '
2+ build : '237de9e0-14b5 -11e7-9970-cb460f4880e6 '
33} ;
44module . exports = CHECKSUM ;
Original file line number Diff line number Diff line change @@ -231,9 +231,9 @@ var Layer = new Class({
231231 return this ;
232232 } ,
233233
234- placeOnRectangle : function ( rect )
234+ placeOnRectangle : function ( rect , shift )
235235 {
236- Actions . PlaceOnRectangle ( this . children . entries , rect ) ;
236+ Actions . PlaceOnRectangle ( this . children . entries , rect , shift ) ;
237237
238238 return this ;
239239 } ,
You can’t perform that action at this time.
0 commit comments