synfig-core
1.0.3
|
#include <color.h>
Public Types | |
enum | BlendMethod { BLEND_COMPOSITE = 0, BLEND_STRAIGHT = 1, BLEND_ONTO = 13, BLEND_STRAIGHT_ONTO = 21, BLEND_BEHIND = 12, BLEND_SCREEN = 16, BLEND_OVERLAY = 20, BLEND_HARD_LIGHT = 17, BLEND_MULTIPLY = 6, BLEND_DIVIDE = 7, BLEND_ADD = 4, BLEND_SUBTRACT = 5, BLEND_DIFFERENCE = 18, BLEND_BRIGHTEN = 2, BLEND_DARKEN = 3, BLEND_COLOR = 8, BLEND_HUE = 9, BLEND_SATURATION = 10, BLEND_LUMINANCE = 11, BLEND_ALPHA_BRIGHTEN = 14, BLEND_ALPHA_DARKEN = 15, BLEND_ALPHA_OVER = 19, BLEND_END = 22, BLEND_BY_LAYER = 999 } |
typedef ColorReal | value_type |
Public Member Functions | |
const String | get_string (void) const |
Color & | operator+= (const Color &rhs) |
Color & | operator-= (const Color &rhs) |
Color & | operator*= (const float &rhs) |
Color & | operator/= (const float &rhs) |
Color | operator+ (const Color &rhs) const |
Color | operator- (const Color &rhs) const |
Color | operator* (const float &rhs) const |
Color | operator/ (const float &rhs) const |
bool | operator== (const Color &rhs) const |
bool | operator!= (const Color &rhs) const |
Color | operator- () const |
Color | operator~ () const |
Effectively 1.0-color. | |
bool | is_valid () const |
Color | premult_alpha () const |
Color | demult_alpha () const |
Color () | |
Color (const value_type &f) | |
Color (int f) | |
Color (const value_type &R, const value_type &G, const value_type &B, const value_type &A=1) | |
Color (const Color &c, const value_type &A) | |
Color (const Color &c) | |
Copy constructor. | |
Color (const CairoColor &c) | |
Convert from CairoColor to Color. | |
const value_type & | get_r () const |
Copy constructor. | |
const value_type & | get_g () const |
Returns the GREEN component. | |
const value_type & | get_b () const |
Returns the BLUE component. | |
const value_type & | get_a () const |
Returns the amount of opacity (alpha) | |
const value_type & | get_alpha () const |
Synonym for get_a(). | |
const String | get_hex () const |
Returns the color as a 6 character hex sting. | |
void | set_hex (String &hex) |
Sets the color's R, G, and B from a 3 or 6 character hex string. | |
Color & | set_r (const value_type &x) |
Sets the RED component to x. | |
Color & | set_g (const value_type &x) |
Sets the GREEN component to x. | |
Color & | set_b (const value_type &x) |
Sets the BLUE component to x. | |
Color & | set_a (const value_type &x) |
Sets the opacity (alpha) to x. | |
Color & | set_alpha (const value_type &x) |
Synonym for set_a(). | |
float | get_y () const |
Returns color's luminance. | |
float | get_u () const |
Returns U component of chromanance. | |
float | get_v () const |
Returns V component of chromanance. | |
float | get_s () const |
Returns the color's saturation. | |
Color & | set_yuv (const float &y, const float &u, const float &v) |
Sets the luminance (y) and chromanance (u and v) | |
Color & | set_y (const float &y) |
Sets color luminance. | |
Color & | set_u (const float &u) |
Set U component of chromanance. | |
Color & | set_v (const float &v) |
Set V component of chromanance. | |
Color & | set_uv (const float &u, const float &v) |
Set the U and V components of chromanance. | |
Color & | set_s (const float &x) |
Sets the color's saturation. | |
Angle | get_hue () const |
Returns the hue of the chromanance. | |
Angle | get_uv_angle () const |
Synonym for get_hue(). | |
Color & | set_hue (const Angle &theta) |
Sets the color's hue. | |
Color & | set_uv_angle (const Angle &theta) |
Synonym for set_hue(). | |
Color & | rotate_uv (const Angle &theta) |
Rotates the chromanance vector by amount specified by theta. | |
Color & | set_yuv (const float &y, const float &s, const Angle &theta) |
Sets the luminance (y) and chromanance (s and theta). | |
Color | clamped () const |
Clamps a color so that its values are in range. Ignores attempting to visualize negative colors. | |
Color | clamped_negative () const |
Clamps a color so that its values are in range. |
Static Public Member Functions | |
static ColorReal | hex2real (String s) |
Converts a 2 character hex string s (00-ff) into a ColorReal (0.0-1.0) | |
static const String | real2hex (ColorReal c) |
Converts a ColorReal c (0.0-1.0) into a 2 character hex string (00-ff) | |
static Color | YUV (const float &y, const float &u, const float &v, const value_type &a=1) |
YUV Color constructor. | |
static Color | YUV (const float &y, const float &s, const Angle &theta, const value_type &a=1) |
YUV color constructor where the chroma is in the saturation/hue form. | |
static Color | blend (Color a, Color b, float amount, BlendMethod type=BLEND_COMPOSITE) |
static bool | is_onto (BlendMethod x) |
static bool | is_straight (BlendMethod x) |
a blending method is considered 'straight' if transparent pixels in the upper layer can affect the result of the blend | |
static Color | alpha () |
Preset Color Constructors. | |
static Color | black () |
Preset Color Constructors. | |
static Color | white () |
Preset Color Constructors. | |
static Color | gray () |
Preset Color Constructors. | |
static Color | magenta () |
Preset Color Constructors. | |
static Color | red () |
Preset Color Constructors. | |
static Color | green () |
Preset Color Constructors. | |
static Color | blue () |
Preset Color Constructors. | |
static Color | cyan () |
Preset Color Constructors. | |
static Color | yellow () |
Preset Color Constructors. |
Static Public Attributes | |
static const value_type | ceil = 1 |
static const value_type | floor = 0 |
\ ARGB 128 bits Color class implementation Future optimizations: lookup table for sqrt()?
typedef ColorReal synfig::Color::value_type |
BLEND_COMPOSITE |
Color A is composited onto B (Taking A's alpha into account) |
BLEND_STRAIGHT |
Straight linear interpolation from A->B (Alpha ignored) |
BLEND_ONTO |
Similar to BLEND_COMPOSITE, except that B's alpha is maintained. |
BLEND_STRAIGHT_ONTO |
|
BLEND_BEHIND |
Similar to BLEND_COMPOSITE, except that B is composited onto A. |
BLEND_SCREEN |
|
BLEND_OVERLAY |
|
BLEND_HARD_LIGHT |
|
BLEND_MULTIPLY |
Simple A*B. |
BLEND_DIVIDE |
Simple B/A. |
BLEND_ADD |
Simple A+B. |
BLEND_SUBTRACT |
Simple A-B. |
BLEND_DIFFERENCE |
Simple |A-B|. |
BLEND_BRIGHTEN |
If composite is brighter than B, use composite. B otherwise. |
BLEND_DARKEN |
If composite is darker than B, use composite. B otherwise. |
BLEND_COLOR |
Preserves the U and V channels of color A. |
BLEND_HUE |
Preserves the angle of the UV vector of color A. |
BLEND_SATURATION |
Preserves the magnitude of the UV Vector of color A. |
BLEND_LUMINANCE |
Preserves the Y channel of color A. |
BLEND_ALPHA_BRIGHTEN |
|
BLEND_ALPHA_DARKEN |
|
BLEND_ALPHA_OVER |
|
BLEND_END | |
BLEND_BY_LAYER |
|
inline |
Referenced by alpha(), black(), blue(), cyan(), demult_alpha(), gray(), green(), magenta(), operator*(), operator+(), operator-(), operator/(), operator~(), premult_alpha(), red(), white(), yellow(), and YUV().
|
inline |
|
inline |
|
inline |
R | Red |
G | Green |
B | Blue |
A | Opacity(alpha) |
|
inline |
c | Source for color components |
A | Opacity(alpha) |
|
inline |
Copy constructor.
|
inline |
Convert from CairoColor to Color.
References ceil, synfig::CairoColor::ceil, floor, synfig::CairoColor::floor, synfig::CairoColor::get_a(), synfig::CairoColor::get_b(), synfig::CairoColor::get_g(), synfig::CairoColor::get_r(), set_a(), set_b(), set_g(), and set_r().
const String Color::get_string | ( | void | ) | const |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
References isnan.
|
inline |
References Color().
Referenced by synfig::Gradient::operator()().
|
inline |
Copy constructor.
Returns the RED component
Referenced by synfig::Layer_SolidColor::accelerated_cairorender(), SimpleCircle::accelerated_cairorender(), CheckerBoard::accelerated_cairorender(), Rectangle::accelerated_cairorender(), synfig::Layer_Shape::accelerated_cairorender(), Layer_Freetype::accelerated_cairorender(), synfig::CairoColor::CairoColor(), clamped(), clamped_negative(), synfig::Color2PixelFormat(), color_neg_flip(), Circle::compile_gradient(), synfig::ColorPrep::cook(), encode_canvas(), encode_color(), yuv::end_frame(), exr_trgt::end_scanline(), imagemagick_mptr::get_frame(), get_u(), get_v(), get_y(), synfig::ValueNode_Scale::operator()(), and Blur::operator()().
|
inline |
Returns the GREEN component.
Referenced by synfig::Layer_SolidColor::accelerated_cairorender(), SimpleCircle::accelerated_cairorender(), CheckerBoard::accelerated_cairorender(), Rectangle::accelerated_cairorender(), synfig::Layer_Shape::accelerated_cairorender(), Layer_Freetype::accelerated_cairorender(), synfig::CairoColor::CairoColor(), clamped(), clamped_negative(), synfig::Color2PixelFormat(), color_neg_flip(), Circle::compile_gradient(), synfig::ColorPrep::cook(), encode_canvas(), encode_color(), yuv::end_frame(), exr_trgt::end_scanline(), imagemagick_mptr::get_frame(), get_u(), get_v(), get_y(), synfig::ValueNode_Scale::operator()(), and Blur::operator()().
|
inline |
Returns the BLUE component.
Referenced by synfig::Layer_SolidColor::accelerated_cairorender(), SimpleCircle::accelerated_cairorender(), CheckerBoard::accelerated_cairorender(), Rectangle::accelerated_cairorender(), synfig::Layer_Shape::accelerated_cairorender(), Layer_Freetype::accelerated_cairorender(), synfig::CairoColor::CairoColor(), clamped(), clamped_negative(), synfig::Color2PixelFormat(), color_neg_flip(), Circle::compile_gradient(), synfig::ColorPrep::cook(), encode_canvas(), encode_color(), yuv::end_frame(), exr_trgt::end_scanline(), imagemagick_mptr::get_frame(), get_u(), get_v(), get_y(), synfig::ValueNode_Scale::operator()(), and Blur::operator()().
|
inline |
Returns the amount of opacity (alpha)
Referenced by synfig::Layer_SolidColor::accelerated_cairorender(), LumaKey::accelerated_cairorender(), SimpleCircle::accelerated_cairorender(), CheckerBoard::accelerated_cairorender(), Rectangle::accelerated_cairorender(), Layer_Bevel::accelerated_cairorender(), synfig::Layer_Shape::accelerated_cairorender(), Layer_Freetype::accelerated_cairorender(), SuperSample::accelerated_render(), Layer_Shade::accelerated_render(), Layer_Bevel::accelerated_render(), synfig::CairoColor::CairoColor(), synfig::cairorender(), clamped(), clamped_negative(), synfig::Color2PixelFormat(), color_neg_flip(), Circle::compile_gradient(), synfig::ColorPrep::cook(), encode_canvas(), encode_color(), exr_trgt::end_scanline(), synfig::Palette::find_closest(), get_alpha(), LumaKey::get_color(), Layer_Shade::get_color(), Layer_Bevel::get_color(), imagemagick_mptr::get_frame(), Rectangle::get_full_bounding_rect(), Circle::get_full_bounding_rect(), synfig::Layer_SolidColor::hit_check(), synfig::Layer_Shape::hit_check(), Rectangle::is_solid_color(), Blur::operator()(), synfig::Palette::Palette(), synfig::parametric_render(), synfig::render(), synfig::render_threaded(), synfig::Layer_SolidColor::set_param(), Layer_Shade::set_param(), synfig::Layer_Shape::set_param(), and Layer_Freetype::set_param().
|
inline |
Converts a 2 character hex string s (00-ff) into a ColorReal (0.0-1.0)
Referenced by synfig::CairoColor::hex2char().
Converts a ColorReal c (0.0-1.0) into a 2 character hex string (00-ff)
References f.
Referenced by synfig::CairoColor::char2hex(), and get_hex().
|
inline |
void Color::set_hex | ( | String & | hex | ) |
Sets the color's R, G, and B from a 3 or 6 character hex string.
Referenced by synfig::CairoColor::set_hex().
|
inline |
Sets the RED component to x.
Referenced by clamped(), clamped_tangent< Color >(), Color(), color_neg_flip(), synfig::ColorPrep::cook(), yuv::end_frame(), exr_mptr::get_frame(), synfig::Palette::load_from_file(), synfig::ValueNode_Composite::operator()(), synfig::ValueNode_Scale::operator()(), Blur::operator()(), synfig::PixelFormat2Color(), png_trgt_spritesheet::read_png_file(), set_yuv(), and synfig::CairoColor::set_yuv().
|
inline |
Sets the GREEN component to x.
Referenced by clamped(), clamped_tangent< Color >(), Color(), color_neg_flip(), synfig::ColorPrep::cook(), yuv::end_frame(), exr_mptr::get_frame(), synfig::Palette::load_from_file(), synfig::ValueNode_Composite::operator()(), synfig::ValueNode_Scale::operator()(), Blur::operator()(), synfig::PixelFormat2Color(), png_trgt_spritesheet::read_png_file(), set_yuv(), and synfig::CairoColor::set_yuv().
|
inline |
Sets the BLUE component to x.
Referenced by clamped(), clamped_tangent< Color >(), Color(), color_neg_flip(), synfig::ColorPrep::cook(), yuv::end_frame(), exr_mptr::get_frame(), synfig::Palette::load_from_file(), synfig::ValueNode_Composite::operator()(), synfig::ValueNode_Scale::operator()(), Blur::operator()(), synfig::PixelFormat2Color(), png_trgt_spritesheet::read_png_file(), set_yuv(), and synfig::CairoColor::set_yuv().
|
inline |
Sets the opacity (alpha) to x.
Referenced by Layer_Shade::accelerated_cairorender(), LumaKey::accelerated_cairorender(), Layer_Bevel::accelerated_cairorender(), SuperSample::accelerated_render(), Layer_Shade::accelerated_render(), LumaKey::accelerated_render(), Layer_Bevel::accelerated_render(), clamped(), clamped_tangent< Color >(), Color(), synfig::Layer_Shape::feather_cairo_surface(), LumaKey::get_color(), Layer_Shade::get_color(), Layer_Bevel::get_color(), exr_mptr::get_frame(), synfig::Palette::load_from_file(), synfig::ValueNode_Composite::operator()(), synfig::PixelFormat2Color(), png_trgt_spritesheet::read_png_file(), set_alpha(), synfig::Layer_SolidColor::set_param(), Layer_Shade::set_param(), synfig::Layer_Shape::set_param(), and Layer_Freetype::set_param().
|
inline |
|
inline |
Returns color's luminance.
References synfig::EncodeYUV, get_b(), get_g(), and get_r().
Referenced by LumaKey::accelerated_cairorender(), synfig::Color2PixelFormat(), yuv::end_frame(), synfig::Palette::find_closest(), LumaKey::get_color(), luma_less_than(), set_u(), set_uv(), and set_v().
|
inline |
Returns U component of chromanance.
References synfig::EncodeYUV, get_b(), get_g(), and get_r().
Referenced by yuv::end_frame(), synfig::Palette::find_closest(), get_hue(), get_s(), rotate_uv(), set_s(), set_v(), and set_y().
|
inline |
Returns V component of chromanance.
References synfig::EncodeYUV, get_b(), get_g(), and get_r().
Referenced by yuv::end_frame(), synfig::Palette::find_closest(), get_hue(), get_s(), rotate_uv(), set_s(), set_u(), and set_y().
|
inline |
|
inline |
Sets the luminance (y) and chromanance (u and v)
References synfig::DecodeYUV, set_b(), set_g(), and set_r().
Referenced by synfig::PixelFormat2Color(), set_u(), set_uv(), set_v(), set_y(), and set_yuv().
|
inline |
Sets color luminance.
References get_u(), get_v(), and set_yuv().
Referenced by LumaKey::accelerated_cairorender(), LumaKey::accelerated_render(), and LumaKey::get_color().
|
inline |
|
inline |
|
inline |
Set the U and V components of chromanance.
References get_y(), and set_yuv().
Referenced by Julia::get_color(), rotate_uv(), set_hue(), and set_s().
|
inline |
|
inlinestatic |
YUV Color constructor.
References Color().
Referenced by synfig::ValueNode_RadialComposite::operator()().
|
inline |
Returns the hue of the chromanance.
This is the angle of the U and V components.
References get_u(), and get_v().
Referenced by get_uv_angle().
|
inline |
Sets the color's hue.
References get_s(), and set_uv().
Referenced by set_uv_angle().
Rotates the chromanance vector by amount specified by theta.
References get_u(), get_v(), and set_uv().
Referenced by Julia::get_color().
Sets the luminance (y) and chromanance (s and theta).
y | Luminance |
s | Saturation |
theta | Hue |
References set_yuv().
|
inlinestatic |
YUV color constructor where the chroma is in the saturation/hue form.
y | Luminance |
s | Saturation |
theta | Hue |
a | Opacity (alpha) |
References Color().
Color Color::clamped | ( | ) | const |
Clamps a color so that its values are in range. Ignores attempting to visualize negative colors.
References get_a(), get_b(), get_g(), get_r(), isnan, set_a(), set_b(), set_g(), and set_r().
Referenced by Layer_Shade::accelerated_cairorender(), LumaKey::accelerated_cairorender(), synfig::Layer_ColorCorrect::accelerated_cairorender(), synfig::cairorender(), yuv::end_frame(), synfig::Layer_Shape::feather_cairo_surface(), synfig::parametric_render(), synfig::render(), synfig::render_threaded(), and synfig::CairoColor::set_hex().
Color Color::clamped_negative | ( | ) | const |
|
inlinestatic |
Preset Color Constructors.
References Color().
Referenced by synfig::Layer_MeshTransform::accelerated_render(), synfig::Layer_SphereDistort::accelerated_render(), demult_alpha(), synfig::Layer_Bitmap::get_color(), synfig::Layer_SphereDistort::get_color(), synfig::Layer_Shape::get_color(), synfig::Layer_PasteCanvas::get_color(), synfig::ColorPrep::uncook(), synfig::ValueNode_Repeat_Gradient::ValueNode_Repeat_Gradient(), and synfig::ValueNode_Stripes::ValueNode_Stripes().
|
inlinestatic |
Preset Color Constructors.
References Color().
Referenced by synfig::Palette::Palette(), and synfig::ValueNode_Stripes::ValueNode_Stripes().
|
inlinestatic |
Preset Color Constructors.
References Color().
Referenced by synfig::Layer_MeshTransform::accelerated_render(), and synfig::Palette::Palette().
|
inlinestatic |
|
static |
References COLOR_EPSILON.
Referenced by synfig::Layer_Shape::accelerated_render(), synfig::Target_Scanline::add_frame(), synfig::blendfunc_COLOR(), synfig::blendfunc_HUE(), synfig::blendfunc_LUMINANCE(), synfig::blendfunc_SATURATION(), synfig::Layer_Duplicate::get_color(), synfig::Layer_SolidColor::get_color(), synfig::Layer_Bitmap::get_color(), synfig::Layer_Shape::get_color(), synfig::Layer_PasteCanvas::get_color(), and synfig::Target_Scanline::render().
|
inlinestatic |
References BLEND_ADD, BLEND_BRIGHTEN, BLEND_COLOR, BLEND_DARKEN, BLEND_DIFFERENCE, BLEND_DIVIDE, BLEND_HARD_LIGHT, BLEND_HUE, BLEND_LUMINANCE, BLEND_MULTIPLY, BLEND_ONTO, BLEND_OVERLAY, BLEND_SATURATION, BLEND_SCREEN, BLEND_STRAIGHT_ONTO, and BLEND_SUBTRACT.
Referenced by synfig::Layer_PasteCanvas::accelerated_render(), synfig::Layer_Composite::get_full_bounding_rect(), synfig::Layer_PasteCanvas::get_full_bounding_rect(), and synfig::Layer_Shape::hit_check().
|
inlinestatic |
a blending method is considered 'straight' if transparent pixels in the upper layer can affect the result of the blend
References BLEND_ALPHA_BRIGHTEN, BLEND_STRAIGHT, and BLEND_STRAIGHT_ONTO.
Referenced by synfig::Layer_PasteCanvas::accelerated_render().
|
static |
Referenced by synfig::CairoColor::CairoColor(), and Color().
|
static |
Referenced by Color().