diff options
author | falkTX <falktx@gmail.com> | 2019-01-07 01:10:57 +0100 |
---|---|---|
committer | falkTX <falktx@gmail.com> | 2019-01-07 01:10:57 +0100 |
commit | 204fbeb807d604042c4cd3fcb076df7906521739 (patch) | |
tree | 5954583a17cf73b4cff5f1f16357b19cb460070f /dgl/src/Color.cpp | |
parent | a3006690997424238f4eac1c1f588cddb671909e (diff) |
Adjustments for Cairo, and general cleanup
Signed-off-by: falkTX <falktx@gmail.com>
Diffstat (limited to 'dgl/src/Color.cpp')
-rw-r--r-- | dgl/src/Color.cpp | 52 |
1 files changed, 13 insertions, 39 deletions
diff --git a/dgl/src/Color.cpp b/dgl/src/Color.cpp index b7079ffe..3fc570ca 100644 --- a/dgl/src/Color.cpp +++ b/dgl/src/Color.cpp @@ -24,6 +24,19 @@ START_NAMESPACE_DGL // ----------------------------------------------------------------------- +static float computeHue(float h, float m1, float m2) +{ + if (h < 0) h += 1; + if (h > 1) h -= 1; + if (h < 1.0f/6.0f) + return m1 + (m2 - m1) * h * 6.0f; + if (h < 3.0f/6.0f) + return m2; + if (h < 4.0f/6.0f) + return m1 + (m2 - m1) * (2.0f/3.0f - h) * 6.0f; + return m1; +} + static void fixRange(float& value) { /**/ if (value < 0.0f) @@ -105,26 +118,8 @@ Color::Color(const Color& color1, const Color& color2, float u) noexcept interpolate(color2, u); } -#ifndef HAVE_DGL -static float computeHue(float h, float m1, float m2) -{ - if (h < 0) h += 1; - if (h > 1) h -= 1; - if (h < 1.0f/6.0f) - return m1 + (m2 - m1) * h * 6.0f; - else if (h < 3.0f/6.0f) - return m2; - else if (h < 4.0f/6.0f) - return m1 + (m2 - m1) * (2.0f/3.0f - h) * 6.0f; - return m1; -} -#endif - Color Color::fromHSL(float hue, float saturation, float lightness, float alpha) { -#ifdef HAVE_DGL - return nvgHSLA(hue, saturation, lightness, static_cast<uchar>(getFixedRange(alpha)*255.0f)); -#else float m1, m2; Color col; hue = fmodf(hue, 1.0f); @@ -139,7 +134,6 @@ Color Color::fromHSL(float hue, float saturation, float lightness, float alpha) col.alpha = alpha; col.fixBounds(); return col; -#endif } Color Color::fromHTML(const char* rgb, float alpha) @@ -258,24 +252,4 @@ void Color::fixBounds() noexcept // ----------------------------------------------------------------------- -#ifndef HAVE_DCAIRO -Color::Color(const NVGcolor& c) noexcept - : red(c.r), green(c.g), blue(c.b), alpha(c.a) -{ - fixBounds(); -} - -Color::operator NVGcolor() const noexcept -{ - NVGcolor nc; - nc.r = red; - nc.g = green; - nc.b = blue; - nc.a = alpha; - return nc; -} -#endif - -// ----------------------------------------------------------------------- - END_NAMESPACE_DGL |