@@ -24,27 +24,27 @@ var deprecated = Common.deprecated;
2424 * Create a new composite containing bodies created in the callback in a grid arrangement.
2525 * This function uses the body's bounds to prevent overlaps.
2626 * @method stack
27- * @param {number } xx
28- * @param {number } yy
27+ * @param {number } x Starting position in X.
28+ * @param {number } y Starting position in Y.
2929 * @param {number } columns
3030 * @param {number } rows
3131 * @param {number } columnGap
3232 * @param {number } rowGap
3333 * @param {function } callback
3434 * @return {composite } A new composite containing objects created in the callback
3535 */
36- Composites . stack = function ( xx , yy , columns , rows , columnGap , rowGap , callback ) {
36+ Composites . stack = function ( x , y , columns , rows , columnGap , rowGap , callback ) {
3737 var stack = Composite . create ( { label : 'Stack' } ) ,
38- x = xx ,
39- y = yy ,
38+ currentX = x ,
39+ currentY = y ,
4040 lastBody ,
4141 i = 0 ;
4242
4343 for ( var row = 0 ; row < rows ; row ++ ) {
4444 var maxHeight = 0 ;
4545
4646 for ( var column = 0 ; column < columns ; column ++ ) {
47- var body = callback ( x , y , column , row , lastBody , i ) ;
47+ var body = callback ( currentX , currentY , column , row , lastBody , i ) ;
4848
4949 if ( body ) {
5050 var bodyHeight = body . bounds . max . y - body . bounds . min . y ,
@@ -55,19 +55,19 @@ var deprecated = Common.deprecated;
5555
5656 Body . translate ( body , { x : bodyWidth * 0.5 , y : bodyHeight * 0.5 } ) ;
5757
58- x = body . bounds . max . x + columnGap ;
58+ currentX = body . bounds . max . x + columnGap ;
5959
6060 Composite . addBody ( stack , body ) ;
6161
6262 lastBody = body ;
6363 i += 1 ;
6464 } else {
65- x += columnGap ;
65+ currentX += columnGap ;
6666 }
6767 }
6868
69- y += maxHeight + rowGap ;
70- x = xx ;
69+ currentY += maxHeight + rowGap ;
70+ currentX = x ;
7171 }
7272
7373 return stack ;
@@ -165,17 +165,17 @@ var deprecated = Common.deprecated;
165165 * Create a new composite containing bodies created in the callback in a pyramid arrangement.
166166 * This function uses the body's bounds to prevent overlaps.
167167 * @method pyramid
168- * @param {number } xx
169- * @param {number } yy
168+ * @param {number } x Starting position in X.
169+ * @param {number } y Starting position in Y.
170170 * @param {number } columns
171171 * @param {number } rows
172172 * @param {number } columnGap
173173 * @param {number } rowGap
174174 * @param {function } callback
175175 * @return {composite } A new composite containing objects created in the callback
176176 */
177- Composites . pyramid = function ( xx , yy , columns , rows , columnGap , rowGap , callback ) {
178- return Composites . stack ( xx , yy , columns , rows , columnGap , rowGap , function ( x , y , column , row , lastBody , i ) {
177+ Composites . pyramid = function ( x , y , columns , rows , columnGap , rowGap , callback ) {
178+ return Composites . stack ( x , y , columns , rows , columnGap , rowGap , function ( stackX , stackY , column , row , lastBody , i ) {
179179 var actualRows = Math . min ( rows , Math . ceil ( columns / 2 ) ) ,
180180 lastBodyWidth = lastBody ? lastBody . bounds . max . x - lastBody . bounds . min . x : 0 ;
181181
@@ -198,29 +198,29 @@ var deprecated = Common.deprecated;
198198
199199 var xOffset = lastBody ? column * lastBodyWidth : 0 ;
200200
201- return callback ( xx + xOffset + column * columnGap , y , column , row , lastBody , i ) ;
201+ return callback ( x + xOffset + column * columnGap , stackY , column , row , lastBody , i ) ;
202202 } ) ;
203203 } ;
204204
205205 /**
206206 * This has now moved to the [newtonsCradle example](https://github.com/liabru/matter-js/blob/master/examples/newtonsCradle.js), follow that instead as this function is deprecated here.
207207 * @deprecated moved to newtonsCradle example
208208 * @method newtonsCradle
209- * @param {number } xx
210- * @param {number } yy
209+ * @param {number } x Starting position in X.
210+ * @param {number } y Starting position in Y.
211211 * @param {number } number
212212 * @param {number } size
213213 * @param {number } length
214214 * @return {composite } A new composite newtonsCradle body
215215 */
216- Composites . newtonsCradle = function ( xx , yy , number , size , length ) {
216+ Composites . newtonsCradle = function ( x , y , number , size , length ) {
217217 var newtonsCradle = Composite . create ( { label : 'Newtons Cradle' } ) ;
218218
219219 for ( var i = 0 ; i < number ; i ++ ) {
220220 var separation = 1.9 ,
221- circle = Bodies . circle ( xx + i * ( size * separation ) , yy + length , size ,
221+ circle = Bodies . circle ( x + i * ( size * separation ) , y + length , size ,
222222 { inertia : Infinity , restitution : 1 , friction : 0 , frictionAir : 0.0001 , slop : 1 } ) ,
223- constraint = Constraint . create ( { pointA : { x : xx + i * ( size * separation ) , y : yy } , bodyB : circle } ) ;
223+ constraint = Constraint . create ( { pointA : { x : x + i * ( size * separation ) , y : y } , bodyB : circle } ) ;
224224
225225 Composite . addBody ( newtonsCradle , circle ) ;
226226 Composite . addConstraint ( newtonsCradle , constraint ) ;
@@ -235,22 +235,22 @@ var deprecated = Common.deprecated;
235235 * This has now moved to the [car example](https://github.com/liabru/matter-js/blob/master/examples/car.js), follow that instead as this function is deprecated here.
236236 * @deprecated moved to car example
237237 * @method car
238- * @param {number } xx
239- * @param {number } yy
238+ * @param {number } x Starting position in X.
239+ * @param {number } y Starting position in Y.
240240 * @param {number } width
241241 * @param {number } height
242242 * @param {number } wheelSize
243243 * @return {composite } A new composite car body
244244 */
245- Composites . car = function ( xx , yy , width , height , wheelSize ) {
245+ Composites . car = function ( x , y , width , height , wheelSize ) {
246246 var group = Body . nextGroup ( true ) ,
247247 wheelBase = 20 ,
248248 wheelAOffset = - width * 0.5 + wheelBase ,
249249 wheelBOffset = width * 0.5 - wheelBase ,
250250 wheelYOffset = 0 ;
251251
252252 var car = Composite . create ( { label : 'Car' } ) ,
253- body = Bodies . rectangle ( xx , yy , width , height , {
253+ body = Bodies . rectangle ( x , y , width , height , {
254254 collisionFilter : {
255255 group : group
256256 } ,
@@ -260,14 +260,14 @@ var deprecated = Common.deprecated;
260260 density : 0.0002
261261 } ) ;
262262
263- var wheelA = Bodies . circle ( xx + wheelAOffset , yy + wheelYOffset , wheelSize , {
263+ var wheelA = Bodies . circle ( x + wheelAOffset , y + wheelYOffset , wheelSize , {
264264 collisionFilter : {
265265 group : group
266266 } ,
267267 friction : 0.8
268268 } ) ;
269269
270- var wheelB = Bodies . circle ( xx + wheelBOffset , yy + wheelYOffset , wheelSize , {
270+ var wheelB = Bodies . circle ( x + wheelBOffset , y + wheelYOffset , wheelSize , {
271271 collisionFilter : {
272272 group : group
273273 } ,
@@ -306,8 +306,8 @@ var deprecated = Common.deprecated;
306306 * and the [cloth example](https://github.com/liabru/matter-js/blob/master/examples/cloth.js), follow those instead as this function is deprecated here.
307307 * @deprecated moved to softBody and cloth examples
308308 * @method softBody
309- * @param {number } xx
310- * @param {number } yy
309+ * @param {number } x Starting position in X.
310+ * @param {number } y Starting position in Y.
311311 * @param {number } columns
312312 * @param {number } rows
313313 * @param {number } columnGap
@@ -318,12 +318,12 @@ var deprecated = Common.deprecated;
318318 * @param { } constraintOptions
319319 * @return {composite } A new composite softBody
320320 */
321- Composites . softBody = function ( xx , yy , columns , rows , columnGap , rowGap , crossBrace , particleRadius , particleOptions , constraintOptions ) {
321+ Composites . softBody = function ( x , y , columns , rows , columnGap , rowGap , crossBrace , particleRadius , particleOptions , constraintOptions ) {
322322 particleOptions = Common . extend ( { inertia : Infinity } , particleOptions ) ;
323323 constraintOptions = Common . extend ( { stiffness : 0.2 , render : { type : 'line' , anchors : false } } , constraintOptions ) ;
324324
325- var softBody = Composites . stack ( xx , yy , columns , rows , columnGap , rowGap , function ( x , y ) {
326- return Bodies . circle ( x , y , particleRadius , particleOptions ) ;
325+ var softBody = Composites . stack ( x , y , columns , rows , columnGap , rowGap , function ( stackX , stackY ) {
326+ return Bodies . circle ( stackX , stackY , particleRadius , particleOptions ) ;
327327 } ) ;
328328
329329 Composites . mesh ( softBody , columns , rows , crossBrace , constraintOptions ) ;
0 commit comments