@@ -19,16 +19,16 @@ var Vector = require('../geometry/Vector');
1919var Mouse = require ( '../core/Mouse' ) ;
2020
2121( function ( ) {
22-
22+
2323 var _requestAnimationFrame ,
2424 _cancelAnimationFrame ;
2525
2626 if ( typeof window !== 'undefined' ) {
2727 _requestAnimationFrame = window . requestAnimationFrame || window . webkitRequestAnimationFrame
28- || window . mozRequestAnimationFrame || window . msRequestAnimationFrame
28+ || window . mozRequestAnimationFrame || window . msRequestAnimationFrame
2929 || function ( callback ) { window . setTimeout ( function ( ) { callback ( Common . now ( ) ) ; } , 1000 / 60 ) ; } ;
30-
31- _cancelAnimationFrame = window . cancelAnimationFrame || window . mozCancelAnimationFrame
30+
31+ _cancelAnimationFrame = window . cancelAnimationFrame || window . mozCancelAnimationFrame
3232 || window . webkitCancelAnimationFrame || window . msCancelAnimationFrame ;
3333 }
3434
@@ -89,12 +89,12 @@ var Mouse = require('../core/Mouse');
8989 render . context = render . canvas . getContext ( '2d' ) ;
9090 render . textures = { } ;
9191
92- render . bounds = render . bounds || {
93- min : {
92+ render . bounds = render . bounds || {
93+ min : {
9494 x : 0 ,
9595 y : 0
96- } ,
97- max : {
96+ } ,
97+ max : {
9898 x : render . canvas . width ,
9999 y : render . canvas . height
100100 }
@@ -106,7 +106,7 @@ var Mouse = require('../core/Mouse');
106106
107107 if ( Common . isElement ( render . element ) ) {
108108 render . element . appendChild ( render . canvas ) ;
109- } else {
109+ } else if ( ! render . canvas . parentNode ) {
110110 Common . log ( 'Render.create: options.element was undefined, render.canvas was created but not appended' , 'warn' ) ;
111111 }
112112
@@ -188,19 +188,19 @@ var Mouse = require('../core/Mouse');
188188 for ( var i = 0 ; i < objects . length ; i += 1 ) {
189189 var object = objects [ i ] ,
190190 min = object . bounds ? object . bounds . min : ( object . min || object . position || object ) ,
191- max = object . bounds ? object . bounds . max : ( object . max || object . position || object ) ;
191+ max = object . bounds ? object . bounds . max : ( object . max || object . position || object ) ;
192192
193- if ( min && max ) {
194- if ( min . x < bounds . min . x )
193+ if ( min && max ) {
194+ if ( min . x < bounds . min . x )
195195 bounds . min . x = min . x ;
196-
197- if ( max . x > bounds . max . x )
196+
197+ if ( max . x > bounds . max . x )
198198 bounds . max . x = max . x ;
199199
200- if ( min . y < bounds . min . y )
200+ if ( min . y < bounds . min . y )
201201 bounds . min . y = min . y ;
202202
203- if ( max . y > bounds . max . y )
203+ if ( max . y > bounds . max . y )
204204 bounds . max . y = max . y ;
205205 }
206206 }
@@ -375,7 +375,7 @@ var Mouse = require('../core/Mouse');
375375
376376 if ( options . showAxes || options . showAngleIndicator )
377377 Render . bodyAxes ( render , bodies , context ) ;
378-
378+
379379 if ( options . showPositions )
380380 Render . bodyPositions ( render , bodies , context ) ;
381381
@@ -456,7 +456,7 @@ var Mouse = require('../core/Mouse');
456456 text += "mid: " + metrics . midEff + space ;
457457 text += "narrow: " + metrics . narrowEff + space ;
458458 }
459- // @endif
459+ // @endif
460460
461461 render . debugString = text ;
462462 render . debugTimestamp = engine . timing . timestamp ;
@@ -519,7 +519,7 @@ var Mouse = require('../core/Mouse');
519519 }
520520 }
521521 } ;
522-
522+
523523 /**
524524 * Description
525525 * @private
@@ -611,20 +611,20 @@ var Mouse = require('../core/Mouse');
611611 var sprite = part . render . sprite ,
612612 texture = _getTexture ( render , sprite . texture ) ;
613613
614- c . translate ( part . position . x , part . position . y ) ;
614+ c . translate ( part . position . x , part . position . y ) ;
615615 c . rotate ( part . angle ) ;
616616
617617 c . drawImage (
618618 texture ,
619- texture . width * - sprite . xOffset * sprite . xScale ,
620- texture . height * - sprite . yOffset * sprite . yScale ,
621- texture . width * sprite . xScale ,
619+ texture . width * - sprite . xOffset * sprite . xScale ,
620+ texture . height * - sprite . yOffset * sprite . yScale ,
621+ texture . width * sprite . xScale ,
622622 texture . height * sprite . yScale
623623 ) ;
624624
625625 // revert translation, hopefully faster than save / restore
626626 c . rotate ( - part . angle ) ;
627- c . translate ( - part . position . x , - part . position . y ) ;
627+ c . translate ( - part . position . x , - part . position . y ) ;
628628 } else {
629629 // part polygon
630630 if ( part . circleRadius ) {
@@ -645,7 +645,7 @@ var Mouse = require('../core/Mouse');
645645 c . moveTo ( part . vertices [ ( j + 1 ) % part . vertices . length ] . x , part . vertices [ ( j + 1 ) % part . vertices . length ] . y ) ;
646646 }
647647 }
648-
648+
649649 c . lineTo ( part . vertices [ 0 ] . x , part . vertices [ 0 ] . y ) ;
650650 c . closePath ( ) ;
651651 }
@@ -715,7 +715,7 @@ var Mouse = require('../core/Mouse');
715715 c . moveTo ( part . vertices [ ( j + 1 ) % part . vertices . length ] . x , part . vertices [ ( j + 1 ) % part . vertices . length ] . y ) ;
716716 }
717717 }
718-
718+
719719 c . lineTo ( part . vertices [ 0 ] . x , part . vertices [ 0 ] . y ) ;
720720 }
721721 }
@@ -755,7 +755,7 @@ var Mouse = require('../core/Mouse');
755755 for ( j = 1 ; j < body . vertices . length ; j ++ ) {
756756 c . lineTo ( body . vertices [ j ] . x , body . vertices [ j ] . y ) ;
757757 }
758-
758+
759759 c . lineTo ( body . vertices [ 0 ] . x , body . vertices [ 0 ] . y ) ;
760760 }
761761
@@ -883,7 +883,7 @@ var Mouse = require('../core/Mouse');
883883 for ( k = 0 ; k < part . axes . length ; k ++ ) {
884884 // render a single axis indicator
885885 c . moveTo ( part . position . x , part . position . y ) ;
886- c . lineTo ( ( part . vertices [ 0 ] . x + part . vertices [ part . vertices . length - 1 ] . x ) / 2 ,
886+ c . lineTo ( ( part . vertices [ 0 ] . x + part . vertices [ part . vertices . length - 1 ] . x ) / 2 ,
887887 ( part . vertices [ 0 ] . y + part . vertices [ part . vertices . length - 1 ] . y ) / 2 ) ;
888888 }
889889 }
@@ -1058,7 +1058,7 @@ var Mouse = require('../core/Mouse');
10581058 c . fill ( ) ;
10591059
10601060 c . beginPath ( ) ;
1061-
1061+
10621062 // render collision normals
10631063 for ( i = 0 ; i < pairs . length ; i ++ ) {
10641064 pair = pairs [ i ] ;
@@ -1076,7 +1076,7 @@ var Mouse = require('../core/Mouse');
10761076 normalPosX = ( pair . activeContacts [ 0 ] . vertex . x + pair . activeContacts [ 1 ] . vertex . x ) / 2 ;
10771077 normalPosY = ( pair . activeContacts [ 0 ] . vertex . y + pair . activeContacts [ 1 ] . vertex . y ) / 2 ;
10781078 }
1079-
1079+
10801080 if ( collision . bodyB === collision . supports [ 0 ] . body || collision . bodyA . isStatic === true ) {
10811081 c . moveTo ( normalPosX - collision . normal . x * 8 , normalPosY - collision . normal . y * 8 ) ;
10821082 } else {
@@ -1183,9 +1183,9 @@ var Mouse = require('../core/Mouse');
11831183 continue ;
11841184
11851185 var region = bucketId . split ( / C | R / ) ;
1186- c . rect ( 0.5 + parseInt ( region [ 1 ] , 10 ) * grid . bucketWidth ,
1187- 0.5 + parseInt ( region [ 2 ] , 10 ) * grid . bucketHeight ,
1188- grid . bucketWidth ,
1186+ c . rect ( 0.5 + parseInt ( region [ 1 ] , 10 ) * grid . bucketWidth ,
1187+ 0.5 + parseInt ( region [ 2 ] , 10 ) * grid . bucketHeight ,
1188+ grid . bucketWidth ,
11891189 grid . bucketHeight ) ;
11901190 }
11911191
@@ -1212,7 +1212,7 @@ var Mouse = require('../core/Mouse');
12121212 boundsHeight = render . bounds . max . y - render . bounds . min . y ,
12131213 boundsScaleX = boundsWidth / render . options . width ,
12141214 boundsScaleY = boundsHeight / render . options . height ;
1215-
1215+
12161216 context . scale ( 1 / boundsScaleX , 1 / boundsScaleY ) ;
12171217 context . translate ( - render . bounds . min . x , - render . bounds . min . y ) ;
12181218 }
@@ -1232,7 +1232,7 @@ var Mouse = require('../core/Mouse');
12321232 // render body selections
12331233 bounds = item . bounds ;
12341234 context . beginPath ( ) ;
1235- context . rect ( Math . floor ( bounds . min . x - 3 ) , Math . floor ( bounds . min . y - 3 ) ,
1235+ context . rect ( Math . floor ( bounds . min . x - 3 ) , Math . floor ( bounds . min . y - 3 ) ,
12361236 Math . floor ( bounds . max . x - bounds . min . x + 6 ) , Math . floor ( bounds . max . y - bounds . min . y + 6 ) ) ;
12371237 context . closePath ( ) ;
12381238 context . stroke ( ) ;
@@ -1266,7 +1266,7 @@ var Mouse = require('../core/Mouse');
12661266 context . fillStyle = 'rgba(255,165,0,0.1)' ;
12671267 bounds = inspector . selectBounds ;
12681268 context . beginPath ( ) ;
1269- context . rect ( Math . floor ( bounds . min . x ) , Math . floor ( bounds . min . y ) ,
1269+ context . rect ( Math . floor ( bounds . min . x ) , Math . floor ( bounds . min . y ) ,
12701270 Math . floor ( bounds . max . x - bounds . min . x ) , Math . floor ( bounds . max . y - bounds . min . y ) ) ;
12711271 context . closePath ( ) ;
12721272 context . stroke ( ) ;
@@ -1444,7 +1444,7 @@ var Mouse = require('../core/Mouse');
14441444 */
14451445
14461446 /**
1447- * A `Bounds` object that specifies the drawing view region.
1447+ * A `Bounds` object that specifies the drawing view region.
14481448 * Rendering will be automatically transformed and scaled to fit within the canvas size (`render.options.width` and `render.options.height`).
14491449 * This allows for creating views that can pan or zoom around the scene.
14501450 * You must also set `render.options.hasBounds` to `true` to enable bounded rendering.
0 commit comments