Skip to content

Commit f26f436

Browse files
committed
Fix set() to support p5.Graphics objects
1 parent fc8ca8a commit f26f436

1 file changed

Lines changed: 10 additions & 1 deletion

File tree

src/core/p5.Renderer2D.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -541,7 +541,16 @@ class Renderer2D extends Renderer {
541541
// round down to get integer numbers
542542
x = Math.floor(x);
543543
y = Math.floor(y);
544-
if (imgOrCol instanceof Image) {
544+
if (imgOrCol instanceof Graphics) {
545+
this.drawingContext.save();
546+
this.drawingContext.setTransform(1, 0, 0, 1, 0, 0);
547+
this.drawingContext.scale(
548+
this._pixelDensity,
549+
this._pixelDensity
550+
);
551+
this.drawingContext.drawImage(imgOrCol.canvas, x, y);
552+
this.drawingContext.restore();
553+
} else if (imgOrCol instanceof Image) {
545554
this.drawingContext.save();
546555
this.drawingContext.setTransform(1, 0, 0, 1, 0, 0);
547556
this.drawingContext.scale(

0 commit comments

Comments
 (0)