Public Member Functions | Static Public Member Functions | Friends

gnash::FuzzyPixel Class Reference

An utility class used to compare rgba values with a given tolerance. More...

#include <FuzzyPixel.h>

List of all members.

Public Member Functions

 FuzzyPixel ()
 Construct an Intollerant FuzzyPixel.
 FuzzyPixel (const rgba &color, short unsigned tolerance=0)
 Construct a FuzzyPixel with given color and tolerance.
 FuzzyPixel (boost::uint8_t r, boost::uint8_t g, boost::uint8_t b, boost::uint8_t a)
 Construct a FuzzyPixel with given values and 0 tolerance.
void setTolerance (unsigned short tol)
 Set the tolerance to use in comparisons.
void setIntolerant ()
 Make this fuzzy pixel intolerant.
bool operator== (const FuzzyPixel &other) const
 Compare two FuzzyPixel using the tolerance of the most tolerant of the two.
 FuzzyPixel ()
 Construct an Intollerant FuzzyPixel.
 FuzzyPixel (const rgba &color, short unsigned tolerance=0)
 Construct a FuzzyPixel with given color and tolerance.
 FuzzyPixel (boost::uint8_t r, boost::uint8_t g, boost::uint8_t b, boost::uint8_t a)
 Construct a FuzzyPixel with given values and 0 tolerance.
void setTolerance (unsigned short tol)
 Set the tolerance to use in comparisons.
void setIntolerant ()
 Make this fuzzy pixel intolerant.
bool operator== (const FuzzyPixel &other) const
 Compare two FuzzyPixel using the tolerance of the most tolerant of the two.

Static Public Member Functions

static bool fuzzyEqual (int a, int b, int tol)
 Return true if a and b are below a given tolerance.
static bool fuzzyEqual (int a, int b, int tol)
 Return true if a and b are below a given tolerance.

Friends

std::ostream & operator<< (std::ostream &o, const FuzzyPixel &p)
std::ostream & operator<< (std::ostream &o, const FuzzyPixel &p)

Detailed Description

An utility class used to compare rgba values with a given tolerance.

This is simply a wrapper around an rgba value, with an associated tolerance used when comparing with another FuzzyPixel.

Currently (but we might change this in the future), the tolerance is used to compare red, green, blue and alpha values.

A negative tolerance may be used to mark the FuzzyPixel as an "invalid" one, which is a FuzzyPixel that will never be equal to any other. Intollerant FuzzyPixel.

See operator== for more info.


Constructor & Destructor Documentation

gnash::FuzzyPixel::FuzzyPixel (  )  [inline]

Construct an Intollerant FuzzyPixel.

Intollerant means that any comparison will fail. Actual value of the pixel doesn't make much sense.

gnash::FuzzyPixel::FuzzyPixel ( const rgba color,
short unsigned  tolerance = 0 
) [inline]

Construct a FuzzyPixel with given color and tolerance.

Parameters:
color The color value
tolerance The tolerance to use in comparisons.
gnash::FuzzyPixel::FuzzyPixel ( boost::uint8_t  r,
boost::uint8_t  g,
boost::uint8_t  b,
boost::uint8_t  a 
) [inline]

Construct a FuzzyPixel with given values and 0 tolerance.

Use setTolerance to modify the tolerance value.

Parameters:
r The red value.
g The green value.
b The blue value.
a The alpha value.
gnash::FuzzyPixel::FuzzyPixel (  )  [inline]

Construct an Intollerant FuzzyPixel.

Intollerant means that any comparison will fail. Actual value of the pixel doesn't make much sense.

gnash::FuzzyPixel::FuzzyPixel ( const rgba color,
short unsigned  tolerance = 0 
) [inline]

Construct a FuzzyPixel with given color and tolerance.

Parameters:
color The color value
tolerance The tolerance to use in comparisons.
gnash::FuzzyPixel::FuzzyPixel ( boost::uint8_t  r,
boost::uint8_t  g,
boost::uint8_t  b,
boost::uint8_t  a 
) [inline]

Construct a FuzzyPixel with given values and 0 tolerance.

Use setTolerance to modify the tolerance value.

Parameters:
r The red value.
g The green value.
b The blue value.
a The alpha value.

Member Function Documentation

static bool gnash::FuzzyPixel::fuzzyEqual ( int  a,
int  b,
int  tol 
) [inline, static]

Return true if a and b are below a given tolerance.

Referenced by operator==().

static bool gnash::FuzzyPixel::fuzzyEqual ( int  a,
int  b,
int  tol 
) [inline, static]

Return true if a and b are below a given tolerance.

bool gnash::FuzzyPixel::operator== ( const FuzzyPixel other  )  const

Compare two FuzzyPixel using the tolerance of the most tolerant of the two.

Note that if any of the two operands is intolerant, any equality comparison will fail.

See default constructor and setIntolerant for more info.

References fuzzyEqual(), gnash::rgba::m_a, gnash::rgba::m_b, gnash::rgba::m_g, and gnash::rgba::m_r.

bool gnash::FuzzyPixel::operator== ( const FuzzyPixel other  )  const

Compare two FuzzyPixel using the tolerance of the most tolerant of the two.

Note that if any of the two operands is intolerant, any equality comparison will fail.

See default constructor and setIntolerant for more info.

void gnash::FuzzyPixel::setIntolerant (  )  [inline]

Make this fuzzy pixel intolerant.

void gnash::FuzzyPixel::setIntolerant (  )  [inline]

Make this fuzzy pixel intolerant.

void gnash::FuzzyPixel::setTolerance ( unsigned short  tol  )  [inline]

Set the tolerance to use in comparisons.

Parameters:
tol The tolerance to use in comparisons.
void gnash::FuzzyPixel::setTolerance ( unsigned short  tol  )  [inline]

Set the tolerance to use in comparisons.

Parameters:
tol The tolerance to use in comparisons.

Friends And Related Function Documentation

std::ostream& operator<< ( std::ostream &  o,
const FuzzyPixel p 
) [friend]
std::ostream& operator<< ( std::ostream &  o,
const FuzzyPixel p 
) [friend]

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