82 static const std::vector<COLOR_SCALAR_CASE> cases = {
83 { { 0.0, 0.25, 1.0, 1.0 }, 0.0, { 1.0, 0.75, 0.0, 1.0 } },
86 for(
const auto& c : cases )
90 const auto inverted = col.Inverted();
105 static const std::vector<COLOR_SCALAR_CASE> cases = {
106 { { 0.0, 0.0, 0.0, 1.0 }, 0.5, { 0.5, 0.5, 0.5, 1.0 } },
107 { { 0.0, 0.5, 1.0, 1.0 }, 0.5, { 0.5, 0.75, 1.0, 1.0 } },
110 for(
const auto& c : cases )
114 const auto brightened = col.Brightened( c.factor );
118 col.Brighten( c.factor );
129 static const std::vector<COLOR_SCALAR_CASE> cases = {
130 { { 0.0, 0.0, 0.0, 1.0 }, 0.5, { 0.0, 0.0, 0.0, 1.0 } },
131 { { 1.0, 1.0, 1.0, 1.0 }, 0.5, { 0.5, 0.5, 0.5, 1.0 } },
134 for(
const auto& c : cases )
138 const auto brightened = col.Darkened( c.factor );
142 col.Darken( c.factor );
153 static const std::vector<COLOR_SCALAR_CASE> cases = {
154 { { 0.0, 0.0, 0.0, 1.0 }, 0.5, { 0.0, 0.0, 0.0, 0.5 } },
155 { { 0.0, 0.5, 1.0, 1.0 }, 0.5, { 0.0, 0.5, 1.0, 0.5 } },
158 for(
const auto& c : cases )
162 const auto with_alpha = col.WithAlpha( c.factor );
187 static const std::vector<FROM_HSV_TO_HEX_CASE> cases = {
188 { 10, 0.71, 0.66, 168, 69, 49 },
189 { 15, 0.96, 0.34, 87, 24, 3 },
190 { 120, 0.50, 0.50, 64, 128, 64 },
191 { 190, 0.32, 0.97, 168, 234, 247 },
192 { 240, 0.15, 0.75, 163, 163, 191 },
193 { 240, 0.90, 0.75, 19, 19, 191 },
194 { 310, 0.71, 0.66, 168, 49, 148 },
195 { 331, 0.15, 0.85, 217, 184, 200 },
198 for(
const auto& c : cases )
202 double new_h, new_s, new_v;
203 col.ToHSV( new_h, new_s, new_v );
204 const unsigned char alpha = 0xFF;
207 BOOST_CHECK_CLOSE( c.h, new_h, 0.0001 );
208 BOOST_CHECK_CLOSE( c.s, new_s, 0.0001 );
209 BOOST_CHECK_CLOSE( c.v, new_v, 0.0001 );
229 static const std::vector<FROM_HSL_TO_HEX_CASE> cases = {
230 { 10, 0.71, 0.66, 230, 127, 107 },
231 { 15, 0.96, 0.34, 170, 45, 3 },
232 { 120, 0.5, 0.5, 64, 191, 64 },
233 { 190, 0.32, 0.97, 245, 249, 250 },
234 { 240, 0.15, 0.75, 182, 182, 201 },
235 { 240, 0.90, 0.75, 134, 134, 249 },
236 { 310, 0.71, 0.66, 230, 107, 209 },
237 { 331, 0.15, 0.85, 222, 211, 217 },
240 for(
const auto& c : cases )
244 double new_h, new_s, new_l;
245 col.ToHSL( new_h, new_s, new_l );
246 const unsigned char alpha = 0xFF;
249 BOOST_CHECK_CLOSE( c.h, new_h, 0.0001 );
250 BOOST_CHECK_CLOSE( c.s, new_s, 0.0001 );
251 BOOST_CHECK_CLOSE( c.l, new_l, 0.0001 );
264 { { 0x00, 0x00, 0x00, 0x00 }, { 0.0, 0.0, 0.0, 0.0 } },
265 { { 0x66, 0x80, 0x99, 0xB3 }, { 0.4, 0.5, 0.6, 0.7 } },
266 { { 0xFF, 0xFF, 0xFF, 0xFF }, { 1.0, 1.0, 1.0, 1.0 } },
267 { { 0xFF, 0x00, 0x00, 0xFF }, { 0.999, 0.001, 0.0, 1.0 } },
void FromHSV(double aInH, double aInS, double aInV)
Changes currently used color to the one given by hue, saturation and value parameters.
void FromHSL(double aInHue, double aInSaturation, double aInLightness)
Change currently used color to the one given by hue, saturation and lightness parameters.
bool IsColorNearHex(const KIGFX::COLOR4D &aCol, unsigned char r, unsigned char g, unsigned char b, unsigned char a)
Checks if a COLOR4D is close enough to a given RGB char value.
BOOST_CHECK_EQUAL(result, "25.4")