mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2024-12-29 09:22:22 -05:00
Fix empty image drawing (#1605)
Empty raster (for example coming from path with empty bound rasterization, ...) drawing threw error. This change prevent raster drawing in that case. Closes #1320
This commit is contained in:
parent
8202f78453
commit
2968faad51
3 changed files with 16 additions and 1 deletions
|
@ -1,5 +1,13 @@
|
||||||
# Change Log
|
# Change Log
|
||||||
|
|
||||||
|
## Prebuilt version
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- Fix empty image drawing (#1320).
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
## `0.11.8`
|
## `0.11.8`
|
||||||
|
|
||||||
### News
|
### News
|
||||||
|
|
|
@ -753,7 +753,8 @@ var Raster = Item.extend(/** @lends Raster# */{
|
||||||
|
|
||||||
_draw: function(ctx, param, viewMatrix) {
|
_draw: function(ctx, param, viewMatrix) {
|
||||||
var element = this.getElement();
|
var element = this.getElement();
|
||||||
if (element) {
|
// Only draw if image is not empty (#1320).
|
||||||
|
if (element && element.width > 0 && element.height > 0) {
|
||||||
// Handle opacity for Rasters separately from the rest, since
|
// Handle opacity for Rasters separately from the rest, since
|
||||||
// Rasters never draw a stroke. See Item#draw().
|
// Rasters never draw a stroke. See Item#draw().
|
||||||
ctx.globalAlpha = this._opacity;
|
ctx.globalAlpha = this._opacity;
|
||||||
|
|
|
@ -945,3 +945,9 @@ test('Children global matrices are cleared after parent transformation', functio
|
||||||
group.translate(100, 0);
|
group.translate(100, 0);
|
||||||
equals(item.localToGlobal(item.getPointAt(0)), new Point(100, 100));
|
equals(item.localToGlobal(item.getPointAt(0)), new Point(100, 100));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('Item#rasterize() with empty bounds', function() {
|
||||||
|
new Path.Line([0, 0], [100, 0]).rasterize();
|
||||||
|
view.update();
|
||||||
|
expect(0);
|
||||||
|
});
|
||||||
|
|
Loading…
Reference in a new issue