Skip to content

Commit ad5fc69

Browse files
committed
Tidied up generateTexture and added default origins
1 parent d8991c5 commit ad5fc69

1 file changed

Lines changed: 8 additions & 4 deletions

File tree

v3/src/gameobjects/graphics/Graphics.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@ var Graphics = new Class({
3333

3434
this.setPosition(x, y);
3535

36+
this.displayOriginX = 0;
37+
this.displayOriginY = 0;
38+
3639
this.commandBuffer = [];
3740

3841
this.defaultFillColor = -1;
@@ -393,19 +396,20 @@ var Graphics = new Class({
393396

394397
generateTexture: function (key, width, height)
395398
{
396-
var screenWidth = this.scene.sys.game.config.width;
397-
var screenHeight = this.scene.sys.game.config.height;
398-
width = (typeof width === 'number') ? width : screenWidth;
399-
height = (typeof height === 'number') ? height : screenHeight;
399+
if (width === undefined) { width = this.scene.sys.game.config.width; }
400+
if (height === undefined) { height = this.scene.sys.game.config.height; }
400401

401402
Graphics.TargetCamera.setViewport(0, 0, width, height);
402403
Graphics.TargetCamera.scrollX = this.x;
403404
Graphics.TargetCamera.scrollY = this.y;
404405

405406
var texture = this.scene.sys.game.textures.createCanvas(key, width, height);
406407
var ctx = texture.source[0].image.getContext('2d');
408+
407409
texture.add('__BASE', 0, 0, 0, width, height);
410+
408411
this.renderCanvas(this.scene.sys.game.renderer, this, 0, Graphics.TargetCamera, ctx);
412+
409413
if (this.gl)
410414
{
411415
this.scene.sys.game.renderer.uploadCanvasToGPU(ctx.canvas, texture.source[0].glTexture, true);

0 commit comments

Comments
 (0)