using std::min;
ArdourCanvas::Color
-change_alpha (Color c, double a)
+ArdourCanvas::change_alpha (Color c, double a)
{
return ((c & ~0xff) | (lrintf (a*255.0) & 0xff));
}
double cmax;
double cmin;
double delta;
-
+
color_to_rgba (color, r, g, b, a);
-
+
if (r > g) {
cmax = max (r, b);
} else {
return;
}
- if (delta != 0.0) {
+ if (delta != 0.0) {
if (cmax == r) {
h = fmod ((g - b)/delta, 6.0);
} else if (cmax == g) {
} else {
h = ((r - g)/delta) + 4;
}
-
+
h *= 60.0;
-
+
if (h < 0.0) {
/* negative values are legal but confusing, because
they alias positive values.
string
HSV::to_string () const
{
+ PBD::LocaleGuard lg;
stringstream ss;
ss << h << ' ';
ss << s << ' ';
HSV::shade (double factor) const
{
HSV hsv (*this);
-
+
/* algorithm derived from a google palette website
and analysis of their color palettes.
perceptual distance of sqrt ((360^2) + 1 + 1) = 360. The 450
are not evenly spread (Webers Law), so lets use 360 as an
approximation of the number of distinct achromatics.
-
+
So, scale up the achromatic difference to give about
a maximal distance between v = 1.0 and v = 0.0 of 360.
-
+
A difference of about 0.0055 will generate a return value of
2, which is roughly the limit of human perceptual
discrimination for chromatics.
const double xDE = sqrt (((sL - oL) * (sL - oL))
+ ((sA - oA) * (sA - oA))
+ ((sB - oB) * (sB - oB)));
-
+
double xDH;
if (sqrt (xDE) > (sqrt (abs (xDL)) + sqrt (abs (xDC)))) {
xDL /= whtL;
xDC /= whtC * xSC;
xDH /= whtH * xSH;
-
+
return sqrt ((xDL * xDL) + (xDC * xDC) + (xDH * xDH));
}
string
SVAModifier::to_string () const
{
- PBD::LocaleGuard lg ("C");
+ PBD::LocaleGuard lg;
stringstream ss;
switch (type) {
SVAModifier::operator () (HSV& hsv) const
{
HSV r (hsv);
-
+
switch (type) {
case Add:
r.s += _s;
return r;
}
+ArdourCanvas::Color
+ArdourCanvas::color_at_alpha (ArdourCanvas::Color c, double a)
+{
+ double r, g, b, unused;
+ color_to_rgba (c, r, g, b, unused);
+ return rgba_to_color( r,g,b, a );
+}