From 4bf2bf901d460fe0a356bc4199803a924fafad88 Mon Sep 17 00:00:00 2001 From: Neil Brown Date: Mon, 9 Dec 2024 16:27:52 +0000 Subject: [PATCH] Corrected a bug where setting fill or stroke to None actually made it black rather than turning it off. --- .../public_libraries/strype/strype_graphics_internal.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/public/public_libraries/strype/strype_graphics_internal.js b/public/public_libraries/strype/strype_graphics_internal.js index 34c75ea9..6f28a824 100644 --- a/public/public_libraries/strype/strype_graphics_internal.js +++ b/public/public_libraries/strype/strype_graphics_internal.js @@ -149,11 +149,15 @@ var $builtinmodule = function(name) { }); mod.canvas_setFill = new Sk.builtin.func(function(img, color) { const ctx = img.getContext("2d"); - ctx.fillStyle = Sk.ffi.remapToJs(color); + let colorJs = Sk.ffi.remapToJs(color); + // Note 8 zeroes: this is fully transparent, not black: + ctx.fillStyle = colorJs == null ? "#00000000" : colorJs; }); mod.canvas_setStroke = new Sk.builtin.func(function(img, color) { const ctx = img.getContext("2d"); - ctx.strokeStyle = Sk.ffi.remapToJs(color); + let colorJs = Sk.ffi.remapToJs(color); + // Note 8 zeroes: this is fully transparent, not black: + ctx.strokeStyle = colorJs == null ? "#00000000" : colorJs; }); mod.canvas_getPixel = new Sk.builtin.func(function(img, x, y) { const ctx = img.getContext("2d");