Skip to content

Commit

Permalink
Move "zero size SVG" comment for clarity
Browse files Browse the repository at this point in the history
  • Loading branch information
adroitwhiz committed Feb 11, 2021
1 parent a9d70a5 commit c9c2e9e
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/SVGSkin.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,12 +106,13 @@ class SVGSkin extends Skin {
const {width, height} = this._svgMeasurements;
this._canvas.width = width * scale;
this._canvas.height = height * scale;
// Even if the canvas at the current scale has a nonzero size, the image's dimensions are floored pre-scaling.
// e.g. if an image has a width of 0.4 and is being rendered at 3x scale, the canvas will have a width of 1, but
// the image's width will be rounded down to 0 on some browsers (Firefox) prior to being drawn at that scale.
if (
this._canvas.width <= 0 ||
this._canvas.height <= 0 ||
// Even if the canvas at the current scale has a nonzero size, the image's dimensions are floored
// pre-scaling; e.g. if an image has a width of 0.4 and is being rendered at 3x scale, the canvas will have
// a width of 1, but the image's width will be rounded down to 0 on some browsers (Firefox) prior to being
// drawn at that scale, resulting in an IndexSizeError if we attempt to draw it.
this._svgImage.naturalWidth <= 0 ||
this._svgImage.naturalHeight <= 0
) return super.getTexture();
Expand Down

0 comments on commit c9c2e9e

Please sign in to comment.