getImage is always called with valid pixelRatio

This commit is contained in:
Maximilian Krög
2021-07-04 14:32:36 +02:00
parent 5716c614a8
commit 28c40fe93e
+8 -8
View File
@@ -225,19 +225,19 @@ class RegularShape extends ImageStyle {
* @api * @api
*/ */
getImage(pixelRatio) { getImage(pixelRatio) {
if (!this.canvas_[pixelRatio || 1]) { let image = this.canvas_[pixelRatio];
if (!image) {
const renderOptions = this.createRenderOptions(); const renderOptions = this.createRenderOptions();
const context = createCanvasContext2D( const context = createCanvasContext2D(
renderOptions.size * pixelRatio || 1, renderOptions.size * pixelRatio,
renderOptions.size * pixelRatio || 1 renderOptions.size * pixelRatio
); );
this.draw_(renderOptions, context, pixelRatio);
this.draw_(renderOptions, context, pixelRatio || 1); image = context.canvas;
this.canvas_[pixelRatio] = image;
this.canvas_[pixelRatio || 1] = context.canvas;
} }
return this.canvas_[pixelRatio || 1]; return image;
} }
/** /**