mirror of
https://github.com/Orama-Interactive/Pixelorama.git
synced 2025-01-31 07:29:49 +00:00
Shading Tool Hue Shift Fixes + Tweaks (#522)
* Fixed issues with Shading tool Saturation and Value not always being right in Hue Shading mode * Shading tool hue shifting fixes and tweaks Co-authored-by: MrTriPie <MrTriPie>
This commit is contained in:
parent
ed45c86649
commit
de28a9d68e
|
@ -23,8 +23,8 @@ class LightenDarkenOp extends Drawer.ColorOp:
|
||||||
var sat_amount := 10.0
|
var sat_amount := 10.0
|
||||||
var value_amount := 10.0
|
var value_amount := 10.0
|
||||||
|
|
||||||
var hue_lighten_limit := 60.0 / 359.0 # A yellow color
|
var hue_lighten_limit := 60.0 / 360.0 # A yellow color
|
||||||
var hue_darken_limit := 270.0 / 359.0 # A purple color
|
var hue_darken_limit := 240.0 / 360.0 # A blue color
|
||||||
|
|
||||||
var sat_lighten_limit := 10.0 / 100.0
|
var sat_lighten_limit := 10.0 / 100.0
|
||||||
var value_darken_limit := 10.0 / 100.0
|
var value_darken_limit := 10.0 / 100.0
|
||||||
|
@ -40,25 +40,25 @@ class LightenDarkenOp extends Drawer.ColorOp:
|
||||||
elif strength < 0:
|
elif strength < 0:
|
||||||
dst = dst.darkened(-strength)
|
dst = dst.darkened(-strength)
|
||||||
else:
|
else:
|
||||||
var hue_shift := hue_amount / 359.0
|
var hue_shift := hue_amount / 360.0
|
||||||
var sat_shift := sat_amount / 100.0
|
var sat_shift := sat_amount / 100.0
|
||||||
var value_shift := value_amount / 100.0
|
var value_shift := value_amount / 100.0
|
||||||
|
|
||||||
# If the colors are roughly between yellow and purple,
|
# If the colors are roughly between yellow-green-blue,
|
||||||
# reverse hue direction
|
# reverse hue direction
|
||||||
if !hue_range(dst.h):
|
if hue_range(dst.h):
|
||||||
hue_shift = -hue_shift
|
hue_shift = -hue_shift
|
||||||
|
|
||||||
if lighten_or_darken == LightenDarken.LIGHTEN:
|
if lighten_or_darken == LightenDarken.LIGHTEN:
|
||||||
hue_shift = hue_limit_lighten(dst.h, hue_shift)
|
hue_shift = hue_limit_lighten(dst.h, hue_shift)
|
||||||
dst.h += hue_shift
|
dst.h = fposmod(dst.h + hue_shift, 1)
|
||||||
if dst.s > sat_lighten_limit:
|
if dst.s > sat_lighten_limit:
|
||||||
dst.s = max(dst.s - min(sat_shift, dst.s), sat_lighten_limit)
|
dst.s = max(dst.s - min(sat_shift, dst.s), sat_lighten_limit)
|
||||||
dst.v += value_shift
|
dst.v += value_shift
|
||||||
|
|
||||||
else:
|
else:
|
||||||
hue_shift = hue_limit_darken(dst.h, hue_shift)
|
hue_shift = hue_limit_darken(dst.h, hue_shift)
|
||||||
dst.h -= hue_shift
|
dst.h = fposmod(dst.h - hue_shift, 1)
|
||||||
dst.s += sat_shift
|
dst.s += sat_shift
|
||||||
if dst.v > value_darken_limit:
|
if dst.v > value_darken_limit:
|
||||||
dst.v = max(dst.v - min(value_shift, dst.v), value_darken_limit)
|
dst.v = max(dst.v - min(value_shift, dst.v), value_darken_limit)
|
||||||
|
@ -66,37 +66,45 @@ class LightenDarkenOp extends Drawer.ColorOp:
|
||||||
return dst
|
return dst
|
||||||
|
|
||||||
|
|
||||||
# Returns true if the colors are roughly between red and yellow, and purple and red
|
# Returns true if the colors are roughly between yellow, green and blue
|
||||||
# False when the colors are roughly between yellow and purple (includes green & blue)
|
# False when the colors are roughly between red-orange-yellow, or blue-purple-red
|
||||||
func hue_range(hue : float) -> bool:
|
func hue_range(hue : float) -> bool:
|
||||||
return hue < hue_lighten_limit or hue > hue_darken_limit
|
return hue > hue_lighten_limit and hue < hue_darken_limit
|
||||||
|
|
||||||
|
|
||||||
func hue_limit_lighten(hue : float, hue_shift : float) -> float:
|
func hue_limit_lighten(hue : float, hue_shift : float) -> float:
|
||||||
# Colors between red-yellow and purple-red
|
# Colors between red-orange-yellow and blue-purple-red
|
||||||
if hue_shift > 0:
|
if hue_shift > 0:
|
||||||
# Just colors between red-yellow
|
# Just colors between red-orange-yellow
|
||||||
if hue < hue_darken_limit:
|
if hue < hue_darken_limit:
|
||||||
if hue + hue_shift >= hue_lighten_limit:
|
if hue + hue_shift >= hue_lighten_limit:
|
||||||
hue_shift = 0
|
hue_shift = hue_lighten_limit - hue
|
||||||
|
# Just blue-purple-red
|
||||||
|
else:
|
||||||
|
if hue + hue_shift >= hue_lighten_limit + 1: # +1 looping around the color wheel
|
||||||
|
hue_shift = hue_lighten_limit - hue
|
||||||
|
|
||||||
# Colors between yellow-purple
|
# Colors between yellow-green-blue
|
||||||
elif hue_shift < 0 and hue + hue_shift <= hue_lighten_limit:
|
elif hue_shift < 0 and hue + hue_shift <= hue_lighten_limit:
|
||||||
hue_shift = clamp(hue_shift, -(hue - hue_lighten_limit), 0)
|
hue_shift = hue_lighten_limit - hue
|
||||||
return hue_shift
|
return hue_shift
|
||||||
|
|
||||||
|
|
||||||
func hue_limit_darken(hue : float, hue_shift : float) -> float:
|
func hue_limit_darken(hue : float, hue_shift : float) -> float:
|
||||||
# Colors between red-yellow and purple-red
|
# Colors between red-orange-yellow and blue-purple-red
|
||||||
if hue_shift > 0:
|
if hue_shift > 0:
|
||||||
# Just colors between purple-red
|
# Just colors between red-orange-yellow
|
||||||
if hue > hue_darken_limit:
|
if hue < hue_darken_limit:
|
||||||
if hue + hue_shift <= hue_darken_limit:
|
if hue - hue_shift <= hue_darken_limit - 1: # -1 looping backwards around the color wheel
|
||||||
hue_shift = 0
|
hue_shift = hue - hue_darken_limit
|
||||||
|
# Just blue-purple-red
|
||||||
|
else:
|
||||||
|
if hue - hue_shift <= hue_darken_limit:
|
||||||
|
hue_shift = hue - hue_darken_limit
|
||||||
|
|
||||||
# Colors between yellow-purple
|
# Colors between yellow-green-blue
|
||||||
elif hue_shift < 0 and hue - hue_shift >= hue_darken_limit:
|
elif hue_shift < 0 and hue - hue_shift >= hue_darken_limit:
|
||||||
hue_shift = clamp(hue_shift, -(hue_darken_limit - hue), 0)
|
hue_shift = hue - hue_darken_limit
|
||||||
return hue_shift
|
return hue_shift
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -113,7 +113,7 @@ margin_bottom = 42.0
|
||||||
hint_tooltip = "Lighten/Darken amount"
|
hint_tooltip = "Lighten/Darken amount"
|
||||||
mouse_default_cursor_shape = 2
|
mouse_default_cursor_shape = 2
|
||||||
size_flags_horizontal = 4
|
size_flags_horizontal = 4
|
||||||
max_value = 359.0
|
max_value = 180.0
|
||||||
value = 10.0
|
value = 10.0
|
||||||
align = 1
|
align = 1
|
||||||
|
|
||||||
|
@ -128,7 +128,7 @@ focus_mode = 0
|
||||||
mouse_default_cursor_shape = 2
|
mouse_default_cursor_shape = 2
|
||||||
size_flags_horizontal = 4
|
size_flags_horizontal = 4
|
||||||
size_flags_vertical = 1
|
size_flags_vertical = 1
|
||||||
max_value = 359.0
|
max_value = 180.0
|
||||||
value = 10.0
|
value = 10.0
|
||||||
ticks_on_borders = true
|
ticks_on_borders = true
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue