use the selected pen color model (hsl or hsv) for graphic effects

snap7
jmoenig 2021-11-10 17:05:16 +01:00
rodzic baee1e1561
commit 471f9fec00
2 zmienionych plików z 6 dodań i 5 usunięć

Wyświetl plik

@ -56,7 +56,8 @@
* objects, store: new "penColorModel" setting, can e 'hsv' or 'hsl' * objects, store: new "penColorModel" setting, can e 'hsv' or 'hsl'
* gui, objects: new (hidden) pen-color-model preference setting (per session) * gui, objects: new (hidden) pen-color-model preference setting (per session)
* objects: changed the scale of the graphics color effect from 0-200 to 0-100 * objects: changed the scale of the graphics color effect from 0-200 to 0-100
* objects: refactored graphics color effect to reuse Morphic's conversion methods * objects: refactored graphics color effect to reuse Morphic's conversion methods
* objects: use the selected pen color model (hsl or hsv) for graphic effects
### 2021-11-09 ### 2021-11-09
* objects, store: refactored block-migration mechanism * objects, store: refactored block-migration mechanism

Wyświetl plik

@ -5162,7 +5162,7 @@ SpriteMorph.prototype.applyGraphicsEffects = function (canvas) {
return imagedata; return imagedata;
} }
function transform_HSV( function transform_colorDimensions(
imagedata, imagedata,
hueShift, hueShift,
saturationShift, saturationShift,
@ -5179,7 +5179,7 @@ SpriteMorph.prototype.applyGraphicsEffects = function (canvas) {
clr.g = pixels[index + 1]; clr.g = pixels[index + 1];
clr.b = pixels[index + 2]; clr.b = pixels[index + 2];
dim = clr.hsv(); dim = clr[SpriteMorph.prototype.penColorModel]();
dim[0] = dim[0] * 100 + hueShift; dim[0] = dim[0] * 100 + hueShift;
if (dim[0] < 0 || dim[0] > 100) { // wrap the hue if (dim[0] < 0 || dim[0] > 100) { // wrap the hue
dim[0] = (dim[0] < 0 ? 100 : 0) + dim[0] % 100; dim[0] = (dim[0] < 0 ? 100 : 0) + dim[0] % 100;
@ -5188,7 +5188,7 @@ SpriteMorph.prototype.applyGraphicsEffects = function (canvas) {
dim[1] = dim[1] + saturationShift / 100; dim[1] = dim[1] + saturationShift / 100;
dim[2] = dim[2] + brightnessShift / 100; dim[2] = dim[2] + brightnessShift / 100;
clr.set_hsv.apply(clr, dim); clr['set_' + SpriteMorph.prototype.penColorModel].apply(clr, dim);
pixels[index] = clr.r; pixels[index] = clr.r;
pixels[index + 1] = clr.g; pixels[index + 1] = clr.g;
pixels[index + 2] = clr.b; pixels[index + 2] = clr.b;
@ -5286,7 +5286,7 @@ SpriteMorph.prototype.applyGraphicsEffects = function (canvas) {
if (this.graphicsValues.color || if (this.graphicsValues.color ||
this.graphicsValues.saturation || this.graphicsValues.saturation ||
this.graphicsValues.brightness) { this.graphicsValues.brightness) {
imagedata = transform_HSV( imagedata = transform_colorDimensions(
imagedata, imagedata,
this.graphicsValues.color, this.graphicsValues.color,
this.graphicsValues.saturation, this.graphicsValues.saturation,