Skip to content

Commit b0df689

Browse files
committed
The Canvas SetTransform method would save the context state, but it wasn't restored at the end in the following Game Objects: Dynamic Bitmap Text, Graphics, Arc, Curve, Ellipse, Grid, IsoBox, IsoTriangle, Line, Polygon, Rectangle, Star and Triangle. These now all restore the context, meaning if you're using non-canvas sized cameras in Canvas mode, it will now render beyond just the first custom camera.
1 parent 91e4a91 commit b0df689

15 files changed

Lines changed: 46 additions & 18 deletions

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@
116116
* `Particle.index` has been removed, as it's no longer required. Particles don't need to keep track of their index any more.
117117
* The Particle Emitter no longer needs to call the StableSort.inplace during its preUpdate, saving cpu.
118118
* `Particle.resetPosition` is a new method that is called when a particle dies, preparing it ready for firing again in the future.
119+
* The Canvas `SetTransform` method would save the context state, but it wasn't restored at the end in the following Game Objects: Dynamic Bitmap Text, Graphics, Arc, Curve, Ellipse, Grid, IsoBox, IsoTriangle, Line, Polygon, Rectangle, Star and Triangle. These now all restore the context, meaning if you're using non-canvas sized cameras in Canvas mode, it will now render beyond just the first custom camera.
119120

120121
### Examples and TypeScript
121122

src/gameobjects/bitmaptext/dynamic/DynamicBitmapTextCanvasRenderer.js

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,6 @@ var DynamicBitmapTextCanvasRenderer = function (renderer, src, interpolationPerc
7272

7373
if (src.cropWidth > 0 && src.cropHeight > 0)
7474
{
75-
ctx.save();
7675
ctx.beginPath();
7776
ctx.rect(0, 0, src.cropWidth, src.cropHeight);
7877
ctx.clip();
@@ -167,11 +166,7 @@ var DynamicBitmapTextCanvasRenderer = function (renderer, src, interpolationPerc
167166
lastCharCode = charCode;
168167
}
169168

170-
if (src.cropWidth > 0 && src.cropHeight > 0)
171-
{
172-
ctx.restore();
173-
}
174-
169+
// Restore the context saved in SetTransform
175170
ctx.restore();
176171
};
177172

src/gameobjects/graphics/GraphicsCanvasRenderer.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,6 @@ var GraphicsCanvasRenderer = function (renderer, src, interpolationPercentage, c
4545
var green = 0;
4646
var blue = 0;
4747

48-
ctx.save();
49-
5048
// Reset any currently active paths
5149
ctx.beginPath();
5250

@@ -239,6 +237,7 @@ var GraphicsCanvasRenderer = function (renderer, src, interpolationPercentage, c
239237
}
240238
}
241239

240+
// Restore the context saved in SetTransform
242241
ctx.restore();
243242
};
244243

src/gameobjects/shape/arc/ArcCanvasRenderer.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,9 @@ var ArcCanvasRenderer = function (renderer, src, interpolationPercentage, camera
6161

6262
ctx.stroke();
6363
}
64+
65+
// Restore the context saved in SetTransform
66+
ctx.restore();
6467
}
6568
};
6669

src/gameobjects/shape/curve/CurveCanvasRenderer.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,9 @@ var CurveCanvasRenderer = function (renderer, src, interpolationPercentage, came
7373

7474
ctx.stroke();
7575
}
76+
77+
// Restore the context saved in SetTransform
78+
ctx.restore();
7679
}
7780
};
7881

src/gameobjects/shape/ellipse/EllipseCanvasRenderer.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,9 @@ var EllipseCanvasRenderer = function (renderer, src, interpolationPercentage, ca
7070

7171
ctx.stroke();
7272
}
73+
74+
// Restore the context saved in SetTransform
75+
ctx.restore();
7376
}
7477
};
7578

src/gameobjects/shape/grid/GridCanvasRenderer.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,9 @@ var RectangleCanvasRenderer = function (renderer, src, interpolationPercentage,
5959

6060
ctx.stroke();
6161
}
62+
63+
// Restore the context saved in SetTransform
64+
ctx.restore();
6265
}
6366
};
6467

src/gameobjects/shape/isobox/IsoBoxCanvasRenderer.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,9 @@ var IsoBoxCanvasRenderer = function (renderer, src, interpolationPercentage, cam
8686

8787
ctx.fill();
8888
}
89+
90+
// Restore the context saved in SetTransform
91+
ctx.restore();
8992
}
9093
};
9194

src/gameobjects/shape/isotriangle/IsoTriangleCanvasRenderer.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,9 @@ var IsoTriangleCanvasRenderer = function (renderer, src, interpolationPercentage
9999

100100
ctx.fill();
101101
}
102+
103+
// Restore the context saved in SetTransform
104+
ctx.restore();
102105
}
103106
};
104107

src/gameobjects/shape/line/LineCanvasRenderer.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,9 @@ var LineCanvasRenderer = function (renderer, src, interpolationPercentage, camer
4242

4343
ctx.stroke();
4444
}
45+
46+
// Restore the context saved in SetTransform
47+
ctx.restore();
4548
}
4649
};
4750

0 commit comments

Comments
 (0)