synfig::Color Class Reference

#include <color.h>

List of all members.

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
}
typedef ColorReal value_type

Public Member Functions

const String get_string (void) const
Coloroperator+= (const Color &rhs)
Coloroperator-= (const Color &rhs)
Coloroperator*= (const float &rhs)
Coloroperator/= (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.
const value_typeget_r () const
 Copy constructor.
const value_typeget_g () const
 Returns the GREEN component.
const value_typeget_b () const
 Returns the BLUE component.
const value_typeget_a () const
 Returns the amount of opacity (alpha).
const value_typeget_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.
Colorset_r (const value_type &x)
 Sets the RED component to x.
Colorset_g (const value_type &x)
 Sets the GREEN component to x.
Colorset_b (const value_type &x)
 Sets the BLUE component to x.
Colorset_a (const value_type &x)
 Sets the opacity (alpha) to x.
Colorset_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.
Colorset_yuv (const float &y, const float &u, const float &v)
 Sets the luminance (y) and chromanance (u and v).
Colorset_y (const float &y)
 Sets color luminance.
Colorset_u (const float &u)
 Set U component of chromanance.
Colorset_v (const float &v)
 Set V component of chromanance.
Colorset_uv (const float &u, const float &v)
 Set the U and V components of chromanance.
Colorset_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().
Colorset_hue (const Angle &theta)
 Sets the color's hue.
Colorset_uv_angle (const Angle &theta)
 Synonym for set_hue().
Colorrotate_uv (const Angle &theta)
 Rotates the chromanance vector by amount specified by theta.
Colorset_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.


Detailed Description

Todo:
Writeme Future optimizations: lookup table for sqrt()?

Member Typedef Documentation


Member Enumeration Documentation

Todo:
This needs to be documented further.
Enumerator:
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 
Deprecated:
Todo:
This needs to be documented further.
BLEND_BEHIND  Similar to BLEND_COMPOSITE, except that B is composited onto A.
BLEND_SCREEN 
Todo:
This needs to be documented further.
BLEND_OVERLAY 
Todo:
This needs to be documented further.
BLEND_HARD_LIGHT 
Todo:
This needs to be documented further.
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 
Deprecated:
If A is less opaque than B, use A
BLEND_ALPHA_DARKEN 
Deprecated:
If A is more opaque than B, use B
BLEND_ALPHA_OVER 
Deprecated:
multiply alphas and then straight blends using the amount
BLEND_END 

For internal use only.


Constructor & Destructor Documentation

synfig::Color::Color (  )  [inline]

synfig::Color::Color ( const value_type f  )  [inline]

synfig::Color::Color ( int  f  )  [inline]

synfig::Color::Color ( const value_type R,
const value_type G,
const value_type B,
const value_type A = 1 
) [inline]

Parameters:
R Red
G Green
B Blue
A Opacity(alpha)

synfig::Color::Color ( const Color c,
const value_type A 
) [inline]

Parameters:
c Source for color components
A Opacity(alpha)

synfig::Color::Color ( const Color c  )  [inline]

Copy constructor.


Member Function Documentation

const String Color::get_string ( void   )  const

References get_hex().

Color& synfig::Color::operator+= ( const Color rhs  )  [inline]

References a_, b_, g_, and r_.

Color& synfig::Color::operator-= ( const Color rhs  )  [inline]

References a_, b_, g_, and r_.

Color& synfig::Color::operator*= ( const float &  rhs  )  [inline]

Color& synfig::Color::operator/= ( const float &  rhs  )  [inline]

Color synfig::Color::operator+ ( const Color rhs  )  const [inline]

References Color().

Color synfig::Color::operator- ( const Color rhs  )  const [inline]

References Color().

Color synfig::Color::operator* ( const float &  rhs  )  const [inline]

References Color().

Color synfig::Color::operator/ ( const float &  rhs  )  const [inline]

References Color().

bool synfig::Color::operator== ( const Color rhs  )  const [inline]

References a_, b_, g_, and r_.

bool synfig::Color::operator!= ( const Color rhs  )  const [inline]

References a_, b_, g_, and r_.

Color synfig::Color::operator- (  )  const [inline]

References Color().

Color synfig::Color::operator~ (  )  const [inline]

Effectively 1.0-color.

References Color(), and f.

bool synfig::Color::is_valid (  )  const [inline]

Color synfig::Color::premult_alpha (  )  const [inline]

Color synfig::Color::demult_alpha (  )  const [inline]

References alpha(), and Color().

const value_type& synfig::Color::get_r (  )  const [inline]

const value_type& synfig::Color::get_g (  )  const [inline]

const value_type& synfig::Color::get_b (  )  const [inline]

const value_type& synfig::Color::get_a (  )  const [inline]

const value_type& synfig::Color::get_alpha (  )  const [inline]

Synonym for get_a().

See also:
get_a()

References get_a().

ColorReal Color::hex2real ( String  s  )  [static]

Converts a 2 character hex string s (00-ff) into a ColorReal (0.0-1.0).

Referenced by set_hex().

const String Color::real2hex ( ColorReal  c  )  [static]

Converts a ColorReal c (0.0-1.0) into a 2 character hex string (00-ff).

References f.

Referenced by get_hex().

const String synfig::Color::get_hex (  )  const [inline]

Returns the color as a 6 character hex sting.

References real2hex().

Referenced by get_string().

void Color::set_hex ( String hex  ) 

Sets the color's R, G, and B from a 3 or 6 character hex string.

References hex2real().

Color& synfig::Color::set_r ( const value_type x  )  [inline]

Color& synfig::Color::set_g ( const value_type x  )  [inline]

Color& synfig::Color::set_b ( const value_type x  )  [inline]

Color& synfig::Color::set_a ( const value_type x  )  [inline]

Color& synfig::Color::set_alpha ( const value_type x  )  [inline]

Synonym for set_a().

See also:
set_a()

References set_a().

Referenced by RadialBlur::accelerated_render().

float synfig::Color::get_y (  )  const [inline]

float synfig::Color::get_u (  )  const [inline]

float synfig::Color::get_v (  )  const [inline]

float synfig::Color::get_s (  )  const [inline]

Returns the color's saturation.

This is is the magnitude of the U and V components.

See also:
set_s()

References get_u(), and get_v().

Referenced by blendfunc_SATURATION(), and set_hue().

Color& synfig::Color::set_yuv ( const float &  y,
const float &  u,
const float &  v 
) [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().

Color& synfig::Color::set_y ( const float &  y  )  [inline]

Sets color luminance.

References get_u(), get_v(), and set_yuv().

Referenced by blendfunc_LUMINANCE(), and LumaKey::get_color().

Color& synfig::Color::set_u ( const float &  u  )  [inline]

Set U component of chromanance.

References get_v(), get_y(), and set_yuv().

Color& synfig::Color::set_v ( const float &  v  )  [inline]

Set V component of chromanance.

References get_u(), get_y(), and set_yuv().

Color& synfig::Color::set_uv ( const float &  u,
const float &  v 
) [inline]

Set the U and V components of chromanance.

References get_y(), and set_yuv().

Referenced by blendfunc_COLOR(), Julia::get_color(), rotate_uv(), set_hue(), and set_s().

Color& synfig::Color::set_s ( const float &  x  )  [inline]

Sets the color's saturation.

See also:
get_s()

References get_u(), get_v(), and set_uv().

Referenced by blendfunc_SATURATION().

static Color synfig::Color::YUV ( const float &  y,
const float &  u,
const float &  v,
const value_type a = 1 
) [inline, static]

YUV Color constructor.

References Color().

Referenced by synfig::ValueNode_RadialComposite::operator()().

Angle synfig::Color::get_hue (  )  const [inline]

Returns the hue of the chromanance.

This is the angle of the U and V components.

See also:
set_hue()

References get_u(), and get_v().

Referenced by blendfunc_HUE(), and get_uv_angle().

Angle synfig::Color::get_uv_angle (  )  const [inline]

Synonym for get_hue().

See also:
get_hue()

References get_hue().

Color& synfig::Color::set_hue ( const Angle theta  )  [inline]

Sets the color's hue.

See also:
get_hue()

References get_s(), and set_uv().

Referenced by blendfunc_HUE(), and set_uv_angle().

Color& synfig::Color::set_uv_angle ( const Angle theta  )  [inline]

Synonym for set_hue().

See also:
set_hue()

References set_hue().

Color& synfig::Color::rotate_uv ( const Angle theta  )  [inline]

Rotates the chromanance vector by amount specified by theta.

References get_u(), get_v(), and set_uv().

Referenced by Julia::get_color().

Color& synfig::Color::set_yuv ( const float &  y,
const float &  s,
const Angle theta 
) [inline]

Sets the luminance (y) and chromanance (s and theta).

Parameters:
y Luminance
s Saturation
theta Hue

References set_yuv().

static Color synfig::Color::YUV ( const float &  y,
const float &  s,
const Angle theta,
const value_type a = 1 
) [inline, static]

YUV color constructor where the chroma is in the saturation/hue form.

Parameters:
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 a_, b_, g_, get_a(), get_b(), get_g(), get_r(), r_, set_a(), set_b(), set_g(), and set_r().

Referenced by yuv::end_frame(), synfig::parametric_render(), synfig::render(), and synfig::render_threaded().

Color Color::clamped_negative (  )  const

Clamps a color so that its values are in range.

References a_, alpha(), b_, g_, get_a(), get_b(), get_g(), get_r(), and r_.

Referenced by Julia::get_color().

static Color synfig::Color::alpha (  )  [inline, static]

static Color synfig::Color::black (  )  [inline, static]

static Color synfig::Color::white (  )  [inline, static]

Preset Color Constructors.

References Color().

Referenced by synfig::Palette::Palette().

static Color synfig::Color::gray (  )  [inline, static]

Preset Color Constructors.

References Color(), and f.

static Color synfig::Color::magenta (  )  [inline, static]

Preset Color Constructors.

References Color().

Referenced by blend().

static Color synfig::Color::red (  )  [inline, static]

Preset Color Constructors.

References Color().

static Color synfig::Color::green (  )  [inline, static]

Preset Color Constructors.

References Color().

static Color synfig::Color::blue (  )  [inline, static]

Preset Color Constructors.

References Color().

static Color synfig::Color::cyan (  )  [inline, static]

Preset Color Constructors.

References Color().

static Color synfig::Color::yellow (  )  [inline, static]

Preset Color Constructors.

References Color().

Color Color::blend ( Color  a,
Color  b,
float  amount,
Color::BlendMethod  type = BLEND_COMPOSITE 
) [static]

static bool synfig::Color::is_onto ( BlendMethod  x  )  [inline, static]

static bool synfig::Color::is_straight ( BlendMethod  x  )  [inline, static]

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(), synfig::Context::accelerated_render(), and synfig::optimize_layers().


The documentation for this class was generated from the following files:

Generated on Fri Jul 31 00:01:58 2009 for synfig-core by  doxygen 1.5.6