Sorry - things got really busy. Here’s a quick draft:
def get_deltas(shift = true)
from = texture.average_color
to = material.color
# Get HLS of base color.
base_h, base_s, base_l = from.get_hsl
# Get HLS of new color.
h, s, l = to.get_hsl
if to.is_monochrome? && from.is_monochrome?
h = 0
s = 0
l = l - base_l
else if to.is_monochrome?
h = 0
s = -1
l = l - base_l
else if from.is_monochrome?
l = l - base_l
else
l = l - base_l
s = s - base_s
if shift
h = h - base_h
end
end
return [h, s, l]
end