@@ -54,13 +54,13 @@ PIXI.CanvasGraphics.renderGraphics = function(graphics, context)
5454 context . lineTo ( points [ j * 2 ] , points [ j * 2 + 1 ] ) ;
5555 }
5656
57- if ( shape . closed )
57+ if ( shape . closed )
5858 {
5959 context . lineTo ( points [ 0 ] , points [ 1 ] ) ;
6060 }
6161
6262 // if the first and last point are the same close the path - much neater :)
63- if ( points [ 0 ] === points [ points . length - 2 ] && points [ 1 ] === points [ points . length - 1 ] )
63+ if ( points [ 0 ] === points [ points . length - 2 ] && points [ 1 ] === points [ points . length - 1 ] )
6464 {
6565 context . closePath ( ) ;
6666 }
@@ -211,23 +211,21 @@ PIXI.CanvasGraphics.renderGraphicsMask = function(graphics, context)
211211{
212212 var len = graphics . graphicsData . length ;
213213
214- if ( len === 0 ) return ;
215-
216- if ( len > 1 )
214+ if ( len === 0 )
217215 {
218- len = 1 ;
219- window . console . log ( 'Pixi.js warning: masks in canvas can only mask using the first path in the graphics object' ) ;
216+ return ;
220217 }
221218
222- for ( var i = 0 ; i < 1 ; i ++ )
219+ context . beginPath ( ) ;
220+
221+ for ( var i = 0 ; i < len ; i ++ )
223222 {
224223 var data = graphics . graphicsData [ i ] ;
225224 var shape = data . shape ;
226225
227226 if ( data . type === PIXI . Graphics . POLY )
228227 {
229- context . beginPath ( ) ;
230-
228+
231229 var points = shape . points ;
232230
233231 context . moveTo ( points [ 0 ] , points [ 1 ] ) ;
@@ -238,27 +236,26 @@ PIXI.CanvasGraphics.renderGraphicsMask = function(graphics, context)
238236 }
239237
240238 // if the first and last point are the same close the path - much neater :)
241- if ( points [ 0 ] === points [ points . length - 2 ] && points [ 1 ] === points [ points . length - 1 ] )
239+ if ( points [ 0 ] === points [ points . length - 2 ] && points [ 1 ] === points [ points . length - 1 ] )
242240 {
243241 context . closePath ( ) ;
244242 }
245243
246244 }
247245 else if ( data . type === PIXI . Graphics . RECT )
248246 {
249- context . beginPath ( ) ;
250247 context . rect ( shape . x , shape . y , shape . width , shape . height ) ;
251248 context . closePath ( ) ;
252249 }
253250 else if ( data . type === PIXI . Graphics . CIRC )
254251 {
255252 // TODO - need to be Undefined!
256- context . beginPath ( ) ;
257- context . arc ( shape . x , shape . y , shape . radius , 0 , 2 * Math . PI ) ;
253+ context . arc ( shape . x , shape . y , shape . radius , 0 , 2 * Math . PI ) ;
258254 context . closePath ( ) ;
259255 }
260256 else if ( data . type === PIXI . Graphics . ELIP )
261257 {
258+
262259 // ellipse code taken from: http://stackoverflow.com/questions/2172798/how-to-draw-an-oval-in-html5-canvas
263260
264261 var w = shape . width * 2 ;
@@ -267,8 +264,6 @@ PIXI.CanvasGraphics.renderGraphicsMask = function(graphics, context)
267264 var x = shape . x - w / 2 ;
268265 var y = shape . y - h / 2 ;
269266
270- context . beginPath ( ) ;
271-
272267 var kappa = 0.5522848 ,
273268 ox = ( w / 2 ) * kappa , // control point offset horizontal
274269 oy = ( h / 2 ) * kappa , // control point offset vertical
@@ -286,17 +281,16 @@ PIXI.CanvasGraphics.renderGraphicsMask = function(graphics, context)
286281 }
287282 else if ( data . type === PIXI . Graphics . RREC )
288283 {
289- var pts = shape . points ;
290- var rx = pts [ 0 ] ;
291- var ry = pts [ 1 ] ;
292- var width = pts [ 2 ] ;
293- var height = pts [ 3 ] ;
294- var radius = pts [ 4 ] ;
284+
285+ var rx = shape . x ;
286+ var ry = shape . y ;
287+ var width = shape . width ;
288+ var height = shape . height ;
289+ var radius = shape . radius ;
295290
296291 var maxRadius = Math . min ( width , height ) / 2 | 0 ;
297292 radius = radius > maxRadius ? maxRadius : radius ;
298293
299- context . beginPath ( ) ;
300294 context . moveTo ( rx , ry + radius ) ;
301295 context . lineTo ( rx , ry + height - radius ) ;
302296 context . quadraticCurveTo ( rx , ry + height , rx + radius , ry + height ) ;
@@ -313,7 +307,10 @@ PIXI.CanvasGraphics.renderGraphicsMask = function(graphics, context)
313307
314308PIXI . CanvasGraphics . updateGraphicsTint = function ( graphics )
315309{
316- if ( graphics . tint === 0xFFFFFF ) return ;
310+ if ( graphics . tint === 0xFFFFFF )
311+ {
312+ return ;
313+ }
317314
318315 var tintR = ( graphics . tint >> 16 & 0xFF ) / 255 ;
319316 var tintG = ( graphics . tint >> 8 & 0xFF ) / 255 ;
0 commit comments