Skip to content

Commit 9cb7122

Browse files
committed
Improved code formatting.
1 parent 855831e commit 9cb7122

3 files changed

Lines changed: 25 additions & 30 deletions

File tree

src/pixi/display/Sprite.js

Lines changed: 16 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -337,11 +337,14 @@ PIXI.Sprite.prototype._renderWebGL = function(renderSession, matrix)
337337
PIXI.Sprite.prototype._renderCanvas = function(renderSession, matrix)
338338
{
339339
// If the sprite is not visible or the alpha is 0 then no need to render this element
340-
if (this.visible === false || this.alpha === 0 || this.renderable === false || this.texture.crop.width <= 0 || this.texture.crop.height <= 0) return;
340+
if (this.visible === false || this.alpha === 0 || this.renderable === false || this.texture.crop.width <= 0 || this.texture.crop.height <= 0)
341+
{
342+
return;
343+
}
341344

342-
// They provided an alternative rendering matrix, so use it
343345
var wt = this.worldTransform;
344346

347+
// If they provided an alternative rendering matrix then use it
345348
if (matrix)
346349
{
347350
wt = matrix;
@@ -388,6 +391,12 @@ PIXI.Sprite.prototype._renderCanvas = function(renderSession, matrix)
388391
renderSession.context.setTransform(wt.a, wt.b, wt.c, wt.d, wt.tx * renderSession.resolution, wt.ty * renderSession.resolution);
389392
}
390393

394+
var cw = this.texture.crop.width;
395+
var ch = this.texture.crop.height;
396+
397+
dx /= resolution;
398+
dy /= resolution;
399+
391400
if (this.tint !== 0xFFFFFF)
392401
{
393402
if (this.cachedTint !== this.tint)
@@ -396,29 +405,13 @@ PIXI.Sprite.prototype._renderCanvas = function(renderSession, matrix)
396405
this.tintedTexture = PIXI.CanvasTinter.getTintedTexture(this, this.tint);
397406
}
398407

399-
renderSession.context.drawImage(
400-
this.tintedTexture,
401-
0,
402-
0,
403-
this.texture.crop.width,
404-
this.texture.crop.height,
405-
dx / resolution,
406-
dy / resolution,
407-
this.texture.crop.width / resolution,
408-
this.texture.crop.height / resolution);
408+
renderSession.context.drawImage(this.tintedTexture, 0, 0, cw, ch, dx, dy, cw / resolution, ch / resolution);
409409
}
410410
else
411411
{
412-
renderSession.context.drawImage(
413-
this.texture.baseTexture.source,
414-
this.texture.crop.x,
415-
this.texture.crop.y,
416-
this.texture.crop.width,
417-
this.texture.crop.height,
418-
dx / resolution,
419-
dy / resolution,
420-
this.texture.crop.width / resolution,
421-
this.texture.crop.height / resolution);
412+
var cx = this.texture.crop.x;
413+
var cy = this.texture.crop.y;
414+
renderSession.context.drawImage(this.texture.baseTexture.source, cx, cy, cw, ch, dx, dy, cw / resolution, ch / resolution);
422415
}
423416
}
424417

@@ -431,6 +424,7 @@ PIXI.Sprite.prototype._renderCanvas = function(renderSession, matrix)
431424
{
432425
renderSession.maskManager.popMask(renderSession);
433426
}
427+
434428
};
435429

436430
// some helper functions..

src/pixi/renderers/canvas/CanvasRenderer.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
*/
2020
PIXI.CanvasRenderer = function(width, height, options)
2121
{
22-
if(options)
22+
if (options)
2323
{
2424
for (var i in PIXI.defaultRenderOptions)
2525
{
@@ -31,7 +31,7 @@ PIXI.CanvasRenderer = function(width, height, options)
3131
options = PIXI.defaultRenderOptions;
3232
}
3333

34-
if(!PIXI.defaultRenderer)
34+
if (!PIXI.defaultRenderer)
3535
{
3636
PIXI.defaultRenderer = this;
3737
}

src/pixi/textures/RenderTexture.js

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,10 @@ PIXI.RenderTexture.prototype.resize = function(width, height, updateBase)
179179
*/
180180
PIXI.RenderTexture.prototype.clear = function()
181181
{
182-
if(!this.valid)return;
182+
if (!this.valid)
183+
{
184+
return;
185+
}
183186

184187
if (this.renderer.type === PIXI.WEBGL_RENDERER)
185188
{
@@ -254,7 +257,7 @@ PIXI.RenderTexture.prototype.renderCanvas = function(displayObject, matrix, clea
254257
return;
255258
}
256259

257-
// setWorld Alpha to ensure that the object is renderer at full opacity
260+
// setWorld Alpha to ensure that the object is rendered at full opacity
258261
displayObject.worldAlpha = 1;
259262

260263
// Time to update all the children of the displayObject with the new matrix (what new matrix? there isn't one!)
@@ -268,13 +271,11 @@ PIXI.RenderTexture.prototype.renderCanvas = function(displayObject, matrix, clea
268271
this.textureBuffer.clear();
269272
}
270273

271-
var context = this.textureBuffer.context;
272-
273274
var realResolution = this.renderer.resolution;
274275

275276
this.renderer.resolution = this.resolution;
276277

277-
this.renderer.renderDisplayObject(displayObject, context, matrix);
278+
this.renderer.renderDisplayObject(displayObject, this.textureBuffer.context, matrix);
278279

279280
this.renderer.resolution = realResolution;
280281
};
@@ -293,7 +294,7 @@ PIXI.RenderTexture.prototype.getImage = function()
293294
};
294295

295296
/**
296-
* Will return a a base64 encoded string of this texture. It works by calling RenderTexture.getCanvas and then running toDataURL on that.
297+
* Will return a base64 encoded string of this texture. It works by calling RenderTexture.getCanvas and then running toDataURL on that.
297298
*
298299
* @method getBase64
299300
* @return {String} A base64 encoded string of the texture.

0 commit comments

Comments
 (0)