From 4021f5899ac873eec6ad88745562152dc386bfef Mon Sep 17 00:00:00 2001 From: jmoenig Date: Wed, 10 Nov 2021 14:28:12 +0100 Subject: [PATCH] new (hidden) pen-color-model preference setting (per session) --- HISTORY.md | 1 + snap.html | 2 +- src/gui.js | 18 +++++++++++++++++- src/objects.js | 10 ++++++++-- 4 files changed, 27 insertions(+), 4 deletions(-) diff --git a/HISTORY.md b/HISTORY.md index 71cc77d9..b4e3f4cd 100755 --- a/HISTORY.md +++ b/HISTORY.md @@ -53,6 +53,7 @@ ### 2021-11-10 * objects, store: new "penColorModel" setting, can e 'hsv' or 'hsl' +* gui, objects: new (hidden) pen-color-model preference setting (per session) ### 2021-11-09 * objects, store: refactored block-migration mechanism diff --git a/snap.html b/snap.html index c99d778f..e40d76c1 100755 --- a/snap.html +++ b/snap.html @@ -20,7 +20,7 @@ - + diff --git a/src/gui.js b/src/gui.js index b35b599a..a27de4eb 100644 --- a/src/gui.js +++ b/src/gui.js @@ -86,7 +86,7 @@ BlockVisibilityDialogMorph*/ // Global stuff //////////////////////////////////////////////////////// -modules.gui = '2021-November-09'; +modules.gui = '2021-November-10'; // Declarations @@ -3845,6 +3845,22 @@ IDE_Morph.prototype.settingsMenu = function () { true ); } + addPreference( + 'HSV pen color model', + () => SpriteMorph.prototype.penColorModel = 'hsv', + SpriteMorph.prototype.penColorModel === 'hsv', + null, + null, + true + ); + addPreference( + 'HSL pen color model', + () => SpriteMorph.prototype.penColorModel = 'hsl', + SpriteMorph.prototype.penColorModel === 'hsl', + null, + null, + true + ); addPreference( 'Input sliders', 'toggleInputSliders', diff --git a/src/objects.js b/src/objects.js index ededa66b..37c3b2c7 100644 --- a/src/objects.js +++ b/src/objects.js @@ -4449,7 +4449,10 @@ SpriteMorph.prototype.setColorDimension = function (idx, num) { this.color.a = 1 - n / 100; } else { this.cachedColorDimensions[idx] = n / 100; - this.color.set_hsl.apply(this.color, this.cachedColorDimensions); + this.color['set_' + this.penColorModel].apply( + this.color, + this.cachedColorDimensions + ); } if (!this.costume) { this.rerender(); @@ -9295,7 +9298,10 @@ StageMorph.prototype.setColorDimension = function (idx, num) { this.color.a = 1 - n / 100; } else { this.cachedColorDimensions[idx] = n / 100; - this.color.set_hsl.apply(this.color, this.cachedColorDimensions); + this.color['set_' + SpriteMorph.prototype.penColorModel].apply( + this.color, + this.cachedColorDimensions + ); } this.rerender(); };