31 using namespace ystdex;
40 const SPos x1(pt.X + 1), y1(pt.Y + 1), x2(pt.X + s.Width - 1),
41 y2(pt.Y + s.Height - 1);
50 if(
YB_LIKELY(s.Width > 4 && s.Height > 4))
67 YAssert(
bool(g),
"Invalid graphics context found.");
69 SDst x(pt.X), y(pt.Y);
77 for(
SDst i(0); i < half_size; ++i)
85 for(
SDst i(0); i < half_size; ++i)
93 for(
SDst i(0); i < half_size; ++i)
101 for(
SDst i(0); i < half_size; ++i)
120 ? (r.Width - half_size) : (r.Width + half_size)) / 2;
121 y += (r.Height + 1) / 2;
126 ? (r.Height - half_size) : (r.Height + half_size)) / 2;
127 x += (r.Width + 1) / 2;
137 if(
YB_LIKELY(s.Width > 8 && s.Height > 8))
139 const SPos xmin(pt.X + 4), xmax(xmin + s.Width - 8),
140 ymin(pt.Y + 4), ymax(ymin + s.Height - 8);
153 const u8 r(c.GetR()), g(c.GetG()), b(c.GetB()),
154 min_color(min(min(r, g), b)), max_color(max(max(r, g), b));
157 decltype(hsl_t::l) l;
159 if(min_color == max_color)
160 l = decltype(hsl_t::l)(min_color) / 0x100;
163 const unsigned p(max_color + min_color);
165 l = decltype(hsl_t::l)(p) / 0x200;
172 const mid_t q(max_color - min_color);
174 s = q / (p < 0x100 ? p : 0x200 - p);
177 else if(g == max_color)
178 h = (b - r) / q + 0x2;
179 else if(b == max_color)
180 h = (r - g) / q + 0x4;
184 return {h * 60, s, l};
191 return c.l > 255.F / 0x100 ?
Color(0xFF, 0xFF, 0xFF)
192 :
Color(c.l * 0x100, c.l * 0x100, c.l * 0x100);
196 mid_t t2((c.l < 0.5 ? c.l * (1 + c.s) : (c.l + c.s - c.l * c.s)) * 0x100),
197 t1((c.l * 0x200) - t2);
198 mid_t tmp[3] = {c.h + 120, c.h, c.h - 120}; \
202 for(
size_t i(0); i < 3; ++i)
206 else if(tmp[i] > 360)
209 dc[i] = t1 + (t2 - t1) * tmp[i] / 60;
210 else if(tmp[i] < 180)
212 else if(tmp[i] < 240)
213 dc[i] = t1 + (t2 - t1) * (240 - tmp[i]) / 60;
219 return Color(dc[0], dc[1], dc[2]);
262 pair<Drawing::Color, Drawing::Color>
263 Palette::GetPair(Palette::ColorListType::size_type n1,
264 Palette::ColorListType::size_type n2)
const
266 return make_pair(colors[n1], colors[n2]);