Change Hue/Saturation from addition/subtraction to multiplication (fix #1571)

This commit is contained in:
David Capello 2018-02-08 17:17:20 -03:00
parent d59fd20489
commit 5b217dd5ce
4 changed files with 25 additions and 22 deletions

View File

@ -1,5 +1,5 @@
// Aseprite
// Copyright (C) 2017 David Capello
// Copyright (C) 2017-2018 David Capello
//
// This program is distributed under the terms of
// the End-User License Agreement for Aseprite.
@ -60,7 +60,7 @@ private:
m_sliders.getRelSliderValue(ColorSliders::Channel::HslLightness) / 100.0);
m_filter.setAlpha(
m_sliders.getRelSliderValue(ColorSliders::Channel::Alpha));
m_sliders.getRelSliderValue(ColorSliders::Channel::Alpha) / 100.0);
restartPreview();
}

View File

@ -1,5 +1,5 @@
// Aseprite
// Copyright (C) 2001-2017 David Capello
// Copyright (C) 2001-2018 David Capello
//
// This program is distributed under the terms of
// the End-User License Agreement for Aseprite.
@ -239,17 +239,17 @@ ColorSliders::ColorSliders()
// Same order as in Channel enum
static_assert(Channel::Red == (Channel)0, "");
static_assert(Channel::Alpha == (Channel)10, "");
addSlider(Channel::Red, "R", 0, 255, -255, 255);
addSlider(Channel::Green, "G", 0, 255, -255, 255);
addSlider(Channel::Blue, "B", 0, 255, -255, 255);
addSlider(Channel::Red, "R", 0, 255, -100, 100);
addSlider(Channel::Green, "G", 0, 255, -100, 100);
addSlider(Channel::Blue, "B", 0, 255, -100, 100);
addSlider(Channel::HsvHue, "H", 0, 360, -180, 180);
addSlider(Channel::HsvSaturation, "S", 0, 100, -100, 100);
addSlider(Channel::HsvValue, "V", 0, 100, -100, 100);
addSlider(Channel::HslHue, "H", 0, 360, -180, 180);
addSlider(Channel::HslSaturation, "S", 0, 100, -100, 100);
addSlider(Channel::HslLightness, "L", 0, 100, -100, 100);
addSlider(Channel::Gray, "V", 0, 255, -255, 255);
addSlider(Channel::Alpha, "A", 0, 255, -255, 255);
addSlider(Channel::Gray, "V", 0, 255, -100, 100);
addSlider(Channel::Alpha, "A", 0, 255, -100, 100);
}
void ColorSliders::setColor(const app::Color& color)

View File

@ -1,5 +1,5 @@
// Aseprite
// Copyright (C) 2017 David Capello
// Copyright (C) 2017-2018 David Capello
//
// This program is distributed under the terms of
// the End-User License Agreement for Aseprite.
@ -33,7 +33,7 @@ HueSaturationFilter::HueSaturationFilter()
: m_h(0.0)
, m_s(0.0)
, m_l(0.0)
, m_a(0)
, m_a(0.0)
{
}
@ -52,7 +52,7 @@ void HueSaturationFilter::setLightness(double l)
m_l = l;
}
void HueSaturationFilter::setAlpha(int a)
void HueSaturationFilter::setAlpha(double a)
{
m_a = a;
}
@ -121,7 +121,7 @@ void HueSaturationFilter::applyToGrayscale(FilterManager* filterMgr)
{
gfx::Hsl hsl(gfx::Rgb(k, k, k));
double l = hsl.lightness() + m_l;
double l = hsl.lightness()*(1.0+m_l);
l = MID(0.0, l, 1.0);
hsl.lightness(l);
@ -129,8 +129,10 @@ void HueSaturationFilter::applyToGrayscale(FilterManager* filterMgr)
if (target & TARGET_GRAY_CHANNEL) k = rgb.red();
if (a && (target & TARGET_ALPHA_CHANNEL))
a = MID(0, a+m_a, 255);
if (a && (target & TARGET_ALPHA_CHANNEL)) {
a = a*(1.0+m_a);
a = MID(0, a, 255);
}
}
*(dst_address++) = graya(k, a);
@ -213,10 +215,10 @@ void HueSaturationFilter::applyHslFilterToRgb(
while (h < 0.0) h += 360.0;
h = std::fmod(h, 360.0);
double s = hsl.saturation() + m_s;
double s = hsl.saturation()*(1.0+m_s);
s = MID(0.0, s, 1.0);
double l = hsl.lightness() + m_l;
double l = hsl.lightness()*(1.0+m_l);
l = MID(0.0, l, 1.0);
hsl.hue(h);
@ -227,8 +229,10 @@ void HueSaturationFilter::applyHslFilterToRgb(
if (target & TARGET_RED_CHANNEL ) r = rgb.red();
if (target & TARGET_GREEN_CHANNEL) g = rgb.green();
if (target & TARGET_BLUE_CHANNEL ) b = rgb.blue();
if (a && (target & TARGET_ALPHA_CHANNEL))
a = MID(0, a+m_a, 255);
if (a && (target & TARGET_ALPHA_CHANNEL)) {
a = a*(1.0+m_a);
a = MID(0, a, 255);
}
c = rgba(r, g, b, a);
}

View File

@ -1,5 +1,5 @@
// Aseprite
// Copyright (C) 2017 David Capello
// Copyright (C) 2017-2018 David Capello
//
// This program is distributed under the terms of
// the End-User License Agreement for Aseprite.
@ -22,7 +22,7 @@ namespace filters {
void setHue(double h);
void setSaturation(double s);
void setLightness(double v);
void setAlpha(int a);
void setAlpha(double a);
// Filter implementation
const char* getName();
@ -34,8 +34,7 @@ namespace filters {
void applyToPalette(FilterManager* filterMgr);
void applyHslFilterToRgb(const Target target, doc::color_t& color);
double m_h, m_s, m_l;
int m_a;
double m_h, m_s, m_l, m_a;
doc::PalettePicks m_picks;
bool m_usePalette;
};