color interpolate(const color& a, sample weight, const color& b) noexcept { auto pre_red = interpolate(a.alpha() * a.red(), weight, b.alpha() * b.red()); auto pre_green = interpolate(a.alpha() * a.green(), weight, b.alpha() * b.green()); auto pre_blue = interpolate(a.alpha() * a.blue(), weight, b.alpha() * b.blue()); auto new_alpha = interpolate(a.alpha(), weight, b.alpha()); return {pre_red / new_alpha, pre_green / new_alpha, pre_blue / new_alpha, new_alpha}; }
inline bool operator==(color const& rhs) const { return (red_== rhs.red()) && (green_ == rhs.green()) && (blue_ == rhs.blue()) && (alpha_ == rhs.alpha()); }
color overlay(const color& fg, const color& bg) noexcept { if (opaque(fg) || transparent(bg)) return fg; if (transparent(fg)) return bg; return interpolate(bg, fg.alpha(), color{fg.red(), fg.green(), fg.blue()}); }
void set ( color& c ) { free_color(); set_color ( c.red(), c.green(), c.blue() ); }
void cairo_context::set_color(color const& color, double opacity) { set_color(color.red()/255.0, color.green()/255.0, color.blue()/255.0, color.alpha() * opacity / 255.0); }
static boost::python::tuple getinitargs(const color& c) { using namespace boost::python; return boost::python::make_tuple(c.red(),c.green(),c.blue(),c.alpha()); }
void api::clear_color( const color &c ) { glClearColor( c.red(), c.green(), c.blue(), c.alpha() ); }
void texture::binding::set_border_color( const color &c ) { float color[] = { c.red(), c.green(), c.blue(), c.alpha() }; glTexParameterfv( _target, GL_TEXTURE_BORDER_COLOR, color ); }