Skip to content

Commit c0af525

Browse files
authored
Merge pull request #6524 from acamposuribe/fix_webgl_erase
Fix webgl erase. Resolves #6523
2 parents 39b50ec + ee2c13d commit c0af525

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

src/webgl/p5.RendererGL.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1180,23 +1180,26 @@ p5.RendererGL = class RendererGL extends p5.Renderer {
11801180

11811181
erase(opacityFill, opacityStroke) {
11821182
if (!this._isErasing) {
1183-
this._applyBlendMode(constants.REMOVE);
1183+
this._cachedBlendMode = this.curBlendMode;
11841184
this._isErasing = true;
1185-
1185+
this.blendMode(constants.REMOVE);
11861186
this._cachedFillStyle = this.curFillColor.slice();
11871187
this.curFillColor = [1, 1, 1, opacityFill / 255];
1188-
11891188
this._cachedStrokeStyle = this.curStrokeColor.slice();
11901189
this.curStrokeColor = [1, 1, 1, opacityStroke / 255];
11911190
}
11921191
}
11931192

11941193
noErase() {
11951194
if (this._isErasing) {
1196-
this._isErasing = false;
11971195
this.curFillColor = this._cachedFillStyle.slice();
11981196
this.curStrokeColor = this._cachedStrokeStyle.slice();
1197+
// It's necessary to restore post-erase state. Needs rework
1198+
let temp = this.curBlendMode;
11991199
this.blendMode(this._cachedBlendMode);
1200+
this._cachedBlendMode = temp; // If we don't do this, applyBlendMode() returns null
1201+
this._isErasing = false;
1202+
this._applyBlendMode(); // This sets _cachedBlendMode back to the original blendmode
12001203
}
12011204
}
12021205

0 commit comments

Comments
 (0)