3#define GLM_FORCE_CTOR_INIT
4#include "glm/gtx/wrap.hpp"
19template<
typename PixelType>
53 template<
typename SrcType>
71 float alpha =
limit());
114 void set(
float gray,
float alpha =
limit());
164 float alpha =
limit());
305 void getHsb(
float& hue,
float& saturation,
float& brightness)
const;
328 template<
typename SrcType>
512 const PixelType&
operator [] (std::size_t n)
const;
532 if(
sizeof(PixelType) == 1) {
533 os << (int) color.
r <<
", " << (
int) color.
g <<
", " << (int) color.
b <<
", " << (
int) color.
a;
535 os << color.
r <<
", " << color.
g <<
", " << color.
b <<
", " << color.
a;
549 if(
sizeof(PixelType) == 1) {
551 is >> std::skipws >> component;
554 is >> std::skipws >> component;
557 is >> std::skipws >> component;
560 is >> std::skipws >> component;
563 is >> std::skipws >> color.
r;
565 is >> std::skipws >> color.
g;
567 is >> std::skipws >> color.
b;
569 is >> std::skipws >> color.
a;
601 gainsboro,
ghostWhite,
gold,
goldenRod,
grey,
greenYellow,
honeyDew,
hotPink,
indianRed,
indigo,
609 peachPuff,
peru,
pink,
plum,
powderBlue,
purple,
rosyBrown,
royalBlue,
saddleBrown,
salmon,
610 sandyBrown,
seaGreen,
seaShell,
sienna,
silver,
skyBlue,
slateBlue,
slateGray,
slateGrey,
snow,
611 springGreen,
steelBlue,
blueSteel,
tan,
teal,
thistle,
tomato,
turquoise,
violet,
wheat,
whiteSmoke,
619 template<
typename SrcType>
642template<
typename PixelType>
643template<
typename SrcType>
648template<
typename PixelType>
649template<
typename SrcType>
655template<
typename PixelType>
656template<
typename SrcType>
658 const float srcMax = mom.
limit();
659 const float dstMax = limit();
660 const float factor = dstMax / srcMax;
662 if(
typeid(SrcType) ==
typeid(
float) ||
typeid(SrcType) ==
typeid(
double)) {
664 for(
int i = 0; i < 4; i++){
665 v[i] = glm::clamp(
float(mom[i]), 0.f, 1.f) * factor;
669 for(
int i = 0; i < 4; i++){
670 v[i] = mom[i] * factor;
675template <
typename PixelType>
680template<
typename PixelType>
682 return std::numeric_limits<PixelType>::max();
693 ((0xff & (
unsigned char) r) << 16) |
694 ((0xff & (
unsigned char) g) << 8) |
695 ((0xff & (
unsigned char)
b));
698template<
typename PixelType>
700 return ((
ofColor) *
this).getHex();
705 r = (hexColor >> 16) & 0xff;
706 g = (hexColor >> 8) & 0xff;
707 b = (hexColor >> 0) & 0xff;
711template<
typename PixelType>
ofColor represents a color in openFrameworks.
Definition ofColor.h:20
static const ofColor_< PixelType > snow
Definition ofColor.h:610
friend std::istream & operator>>(std::istream &is, ofColor_< PixelType > &color)
An input stream operator.
Definition ofColor.h:548
static const ofColor_< PixelType > cadetBlue
Definition ofColor.h:596
static const ofColor_< PixelType > darkGrey
Definition ofColor.h:597
static const ofColor_< PixelType > aquamarine
Definition ofColor.h:595
static const ofColor_< PixelType > slateGrey
Definition ofColor.h:610
static const ofColor_< PixelType > fuchsia
Definition ofColor.h:600
static const ofColor_< PixelType > thistle
Definition ofColor.h:611
static const ofColor_< PixelType > royalBlue
Definition ofColor.h:609
ofColor_()
Construct a default white color.
Definition ofColor.h:26
static const ofColor_< PixelType > turquoise
Definition ofColor.h:611
ofColor_< PixelType > & operator*=(const ofColor_< PixelType > &color)
Clamped multiplication operator.
Definition ofColor.cpp:577
static const ofColor_< PixelType > olive
Definition ofColor.h:607
static const ofColor_< PixelType > coral
Definition ofColor.h:596
const PixelType & operator[](std::size_t n) const
Array subscript operator.
Definition ofColor.cpp:629
static const ofColor_< PixelType > limeGreen
Definition ofColor.h:605
static const ofColor_< PixelType > papayaWhip
Definition ofColor.h:608
static const ofColor_< PixelType > bisque
Definition ofColor.h:595
static const ofColor_< PixelType > brown
Definition ofColor.h:596
static const ofColor_< PixelType > mediumTurquoise
Definition ofColor.h:606
static const ofColor_< PixelType > lightSlateGray
Definition ofColor.h:604
static const ofColor_< PixelType > springGreen
Definition ofColor.h:611
ofColor_< PixelType > & operator=(const ofColor_< SrcType > &color)
Assign a color using an existing color.
Definition ofColor.h:650
static const ofColor_< PixelType > darkViolet
Definition ofColor.h:599
float getLightness() const
Calculate the lightness of the R, G and B components.
Definition ofColor.cpp:347
static const ofColor_< PixelType > floralWhite
Definition ofColor.h:600
static const ofColor_< PixelType > mediumSlateBlue
Definition ofColor.h:606
static const ofColor_< PixelType > darkSalmon
Definition ofColor.h:598
static const ofColor_< PixelType > aliceBlue
Definition ofColor.h:595
static const ofColor_< PixelType > plum
Definition ofColor.h:609
static ofColor_< PixelType > fromHsb(float hue, float saturation, float brightness, float alpha=limit())
Create an ofColor_ from an HSB representation.
Definition ofColor.cpp:195
static const ofColor_< PixelType > lightGoldenRodYellow
Definition ofColor.h:603
void setHue(float hue)
Set the hue of this color.
Definition ofColor.cpp:389
static const ofColor_< PixelType > lightGray
Definition ofColor.h:603
static const ofColor_< PixelType > lavender
Definition ofColor.h:602
static const ofColor_< PixelType > sienna
Definition ofColor.h:610
static const ofColor_< PixelType > mediumBlue
Definition ofColor.h:605
static const ofColor_< PixelType > darkMagenta
Definition ofColor.h:598
static const ofColor_< PixelType > darkOrange
Definition ofColor.h:598
static const ofColor_< PixelType > hotPink
Definition ofColor.h:601
static const ofColor_< PixelType > peachPuff
Definition ofColor.h:609
PixelType v[4]
The pixel values as an array.
Definition ofColor.h:94
static const ofColor_< PixelType > oldLace
Definition ofColor.h:607
ofColor_< PixelType > & normalize()
Normalize the R, G and B components.
Definition ofColor.cpp:259
static const ofColor_< PixelType > azure
Definition ofColor.h:595
static const ofColor_< PixelType > peru
Definition ofColor.h:609
void setHsb(float hue, float saturation, float brightness, float alpha=limit())
Set the color using HSB components.
Definition ofColor.cpp:419
static const ofColor_< PixelType > seaGreen
Definition ofColor.h:610
static const ofColor_< PixelType > dimGrey
Definition ofColor.h:600
static const ofColor_< PixelType > gray
Definition ofColor.h:594
static const ofColor_< PixelType > dimGray
Definition ofColor.h:600
static const ofColor_< PixelType > violet
Definition ofColor.h:611
static const ofColor_< PixelType > skyBlue
Definition ofColor.h:610
friend std::ostream & operator<<(std::ostream &os, const ofColor_< PixelType > &color)
An output stream operator.
Definition ofColor.h:531
static const ofColor_< PixelType > honeyDew
Definition ofColor.h:601
static const ofColor_< PixelType > chartreuse
Definition ofColor.h:596
static const ofColor_< PixelType > mediumPurple
Definition ofColor.h:605
ofColor_< PixelType > operator*(const ofColor_< PixelType > &color) const
Clamped multiplication operator.
Definition ofColor.cpp:561
static const ofColor_< PixelType > orangeRed
Definition ofColor.h:608
static const ofColor_< PixelType > lemonChiffon
Definition ofColor.h:602
static const ofColor_< PixelType > lightBlue
Definition ofColor.h:602
static const ofColor_< PixelType > chocolate
Definition ofColor.h:596
bool operator==(const ofColor_< PixelType > &color) const
Test two colors for equality.
Definition ofColor.cpp:483
bool operator!=(const ofColor_< PixelType > &color) const
Test two colors for inequality.
Definition ofColor.cpp:489
static const ofColor_< PixelType > darkSlateBlue
Definition ofColor.h:599
static const ofColor_< PixelType > teal
Definition ofColor.h:611
static const ofColor_< PixelType > steelBlue
Definition ofColor.h:611
static const ofColor_< PixelType > white
Definition ofColor.h:594
static const ofColor_< PixelType > lightSteelBlue
Definition ofColor.h:604
static const ofColor_< PixelType > blanchedAlmond
Definition ofColor.h:595
void setHueAngle(float angle)
Set the hue angle of this color.
Definition ofColor.cpp:398
static const ofColor_< PixelType > salmon
Definition ofColor.h:609
static const ofColor_< PixelType > saddleBrown
Definition ofColor.h:609
ofColor_< PixelType > getNormalized() const
A non-destructive version of normalize().
Definition ofColor.cpp:295
static const ofColor_< PixelType > mediumVioletRed
Definition ofColor.h:606
float getHue() const
Get the Hue of this color.
Definition ofColor.cpp:312
static const ofColor_< PixelType > lime
Definition ofColor.h:605
float getHueAngle() const
Get the Hue angle of this color.
Definition ofColor.cpp:321
static const ofColor_< PixelType > lightGrey
Definition ofColor.h:603
static const ofColor_< PixelType > forestGreen
Definition ofColor.h:600
static const ofColor_< PixelType > purple
Definition ofColor.h:609
ofColor_< PixelType > operator+(const ofColor_< PixelType > &color) const
Clamped addition operator.
Definition ofColor.cpp:495
PixelType g
The green color component.
Definition ofColor.h:90
float getBrightness() const
Calculate the brightness of of the R, G and B components.
Definition ofColor.cpp:335
static const ofColor_< PixelType > darkOrchid
Definition ofColor.h:598
static const ofColor_< PixelType > oliveDrab
Definition ofColor.h:607
static const ofColor_< PixelType > wheat
Definition ofColor.h:611
float getSaturation() const
Get the Saturation of this color.
Definition ofColor.cpp:326
static const ofColor_< PixelType > lightSlateGrey
Definition ofColor.h:604
PixelType r
The red color component.
Definition ofColor.h:89
static const ofColor_< PixelType > lightSeaGreen
Definition ofColor.h:604
static const ofColor_< PixelType > darkGreen
Definition ofColor.h:597
ofColor_< PixelType > & lerp(const ofColor_< PixelType > &target, float amount)
A linear interpolation between all components of two colors.
Definition ofColor.cpp:267
static const ofColor_< PixelType > tomato
Definition ofColor.h:611
ofColor_< PixelType > operator/(const ofColor_< PixelType > &color) const
Clamped division operator.
Definition ofColor.cpp:595
static const ofColor_< PixelType > silver
Definition ofColor.h:610
ofColor_(const ofColor_< SrcType > &color)
Construct an ofColor_ from an existing ofColor_.
Definition ofColor.h:644
static const ofColor_< PixelType > greenYellow
Definition ofColor.h:601
static const ofColor_< PixelType > lavenderBlush
Definition ofColor.h:602
PixelType a
The alpha color component.
Definition ofColor.h:92
static const ofColor_< PixelType > deepPink
Definition ofColor.h:599
static const ofColor_< PixelType > lightYellow
Definition ofColor.h:604
static const ofColor_< PixelType > pink
Definition ofColor.h:609
static const ofColor_< PixelType > lightSkyBlue
Definition ofColor.h:604
static const ofColor_< PixelType > darkKhaki
Definition ofColor.h:597
static const ofColor_< PixelType > beige
Definition ofColor.h:595
static const ofColor_< PixelType > midnightBlue
Definition ofColor.h:607
static const ofColor_< PixelType > ivory
Definition ofColor.h:602
static const ofColor_< PixelType > yellowGreen
Definition ofColor.h:612
ofColor_< PixelType > & clamp()
Clamp values between 0 and the limit().
Definition ofColor.cpp:240
static const ofColor_< PixelType > yellow
Definition ofColor.h:595
static const ofColor_< PixelType > cornsilk
Definition ofColor.h:596
static const ofColor_< PixelType > navajoWhite
Definition ofColor.h:607
static const ofColor_< PixelType > linen
Definition ofColor.h:605
static ofColor_< PixelType > fromHex(int hexColor, float alpha=limit())
Create an ofColor_ from a hexadecimal value.
Definition ofColor.cpp:206
void setSaturation(float saturation)
Set the saturation of this color.
Definition ofColor.cpp:403
static const ofColor_< PixelType > indianRed
Definition ofColor.h:601
static const ofColor_< PixelType > mediumAquaMarine
Definition ofColor.h:605
static const ofColor_< PixelType > grey
Definition ofColor.h:601
static const ofColor_< PixelType > darkOliveGreen
Definition ofColor.h:598
ofColor_< PixelType > getInverted() const
A non-destructive version of invert().
Definition ofColor.cpp:287
static const ofColor_< PixelType > mintCream
Definition ofColor.h:607
static const ofColor_< PixelType > cyan
Definition ofColor.h:594
static const ofColor_< PixelType > indigo
Definition ofColor.h:601
static const ofColor_< PixelType > lawnGreen
Definition ofColor.h:602
static const ofColor_< PixelType > orchid
Definition ofColor.h:608
static const ofColor_< PixelType > darkGoldenRod
Definition ofColor.h:597
static const ofColor_< PixelType > blueSteel
Definition ofColor.h:611
static const ofColor_< PixelType > blueViolet
Definition ofColor.h:596
static const ofColor_< PixelType > mediumSeaGreen
Definition ofColor.h:606
static const ofColor_< PixelType > tan
Definition ofColor.h:611
static const ofColor_< PixelType > black
Definition ofColor.h:594
static const ofColor_< PixelType > aqua
Definition ofColor.h:595
static const ofColor_< PixelType > green
Definition ofColor.h:594
static const ofColor_< PixelType > darkRed
Definition ofColor.h:598
static const ofColor_< PixelType > deepSkyBlue
Definition ofColor.h:600
static const ofColor_< PixelType > powderBlue
Definition ofColor.h:609
static const ofColor_< PixelType > darkGray
Definition ofColor.h:597
static const ofColor_< PixelType > darkCyan
Definition ofColor.h:597
static const ofColor_< PixelType > lightSalmon
Definition ofColor.h:603
static const ofColor_< PixelType > gainsboro
Definition ofColor.h:601
ofColor_< PixelType > operator-(const ofColor_< PixelType > &color) const
Clamped subtraction operator.
Definition ofColor.cpp:528
static const ofColor_< PixelType > red
Definition ofColor.h:594
static const ofColor_< PixelType > antiqueWhite
Definition ofColor.h:595
static const ofColor_< PixelType > burlyWood
Definition ofColor.h:596
int getHex() const
Get a 24-bit hexadecimal representation of the RGB color.
Definition ofColor.h:699
ofColor_< PixelType > getLerped(const ofColor_< PixelType > &target, float amount) const
A non-destructive version of lerp().
Definition ofColor.cpp:303
static const ofColor_< PixelType > goldenRod
Definition ofColor.h:601
ofColor_< PixelType > & invert()
Invert the R, G and B components.
Definition ofColor.cpp:250
static const ofColor_< PixelType > ghostWhite
Definition ofColor.h:601
static const ofColor_< PixelType > paleVioletRed
Definition ofColor.h:608
static const ofColor_< PixelType > rosyBrown
Definition ofColor.h:609
ofColor_< PixelType > & operator+=(const ofColor_< PixelType > &color)
Clamped addition operator.
Definition ofColor.cpp:511
static const ofColor_< PixelType > khaki
Definition ofColor.h:602
static const ofColor_< PixelType > orange
Definition ofColor.h:608
static const ofColor_< PixelType > paleGoldenRod
Definition ofColor.h:608
static const ofColor_< PixelType > cornflowerBlue
Definition ofColor.h:596
static const ofColor_< PixelType > whiteSmoke
Definition ofColor.h:611
static const ofColor_< PixelType > moccasin
Definition ofColor.h:607
ofColor_< PixelType > & operator/=(const ofColor_< PixelType > &color)
Clamped division operator.
Definition ofColor.cpp:611
static const ofColor_< PixelType > blue
Definition ofColor.h:594
static const ofColor_< PixelType > slateGray
Definition ofColor.h:610
void setHex(int hexColor, float alpha=limit())
Set an ofColor_ from a hexadecimal representation.
Definition ofColor.h:712
static const ofColor_< PixelType > maroon
Definition ofColor.h:605
static const ofColor_< PixelType > crimson
Definition ofColor.h:597
static const ofColor_< PixelType > mistyRose
Definition ofColor.h:607
static const ofColor_< PixelType > seaShell
Definition ofColor.h:610
static const ofColor_< PixelType > lightCyan
Definition ofColor.h:603
static const ofColor_< PixelType > darkBlue
Definition ofColor.h:597
static const ofColor_< PixelType > lightPink
Definition ofColor.h:603
static const ofColor_< PixelType > mediumOrchid
Definition ofColor.h:605
ofColor_< PixelType > getClamped() const
A non-destructive version of clamp().
Definition ofColor.cpp:279
void getHsb(float &hue, float &saturation, float &brightness) const
Extract the hue, saturation and brightness (HSB) from this color.
Definition ofColor.cpp:352
static const ofColor_< PixelType > navy
Definition ofColor.h:607
ofColor_< PixelType > & operator-=(const ofColor_< PixelType > &color)
Clamped subtraction operator.
Definition ofColor.cpp:544
void setBrightness(float brightness)
Set the brightness of this color.
Definition ofColor.cpp:411
static const ofColor_< PixelType > gold
Definition ofColor.h:601
static const ofColor_< PixelType > mediumSpringGreen
Definition ofColor.h:606
static const ofColor_< PixelType > paleGreen
Definition ofColor.h:608
static const ofColor_< PixelType > lightGreen
Definition ofColor.h:603
static const ofColor_< PixelType > paleTurquoise
Definition ofColor.h:608
static const ofColor_< PixelType > darkSlateGrey
Definition ofColor.h:599
static float limit()
Get the maximum value of a color component.
Definition ofColor.h:681
static const ofColor_< PixelType > lightCoral
Definition ofColor.h:602
static const ofColor_< PixelType > dodgerBlue
Definition ofColor.h:600
static const ofColor_< PixelType > darkSlateGray
Definition ofColor.h:599
static const ofColor_< PixelType > darkSeaGreen
Definition ofColor.h:598
static const ofColor_< PixelType > fireBrick
Definition ofColor.h:600
PixelType b
The blue color component.
Definition ofColor.h:91
static const ofColor_< PixelType > darkTurquoise
Definition ofColor.h:599
static const ofColor_< PixelType > sandyBrown
Definition ofColor.h:610
static const ofColor_< PixelType > slateBlue
Definition ofColor.h:610
static const ofColor_< PixelType > magenta
Definition ofColor.h:594
ofColor_< unsigned char > ofColor
Definition ofColor.h:629
ofColor_< float > ofFloatColor
Definition ofColor.h:637
ofColor_< PixelType > operator*(float val, const ofColor_< PixelType > &color)
Definition ofColor.h:676
ofColor_< unsigned short > ofShortColor
Definition ofColor.h:633