ofDoc > types > ofBaseTypes

ofBaseTypesfile

Variants

ofColor typedef

Typedefs

ofImage typedef
ofFloatImage typedef
ofShortImage typedef
ofPixels typedef
ofFloatPixels typedef
ofShortPixels typedef
ofPixelsRef typedef
ofPoint typedef
ofBaseHasPixels typedef
ofBaseImage typedef

Functions

ofImage_class

template<typename PixelType>
class ofImage_< PixelType >

A class representing an image using memory and gpu based pixels.

Template Parameters
PixelTypeThe data type used to represent a single pixel value.

Image Construction

clear ()
clone ()
load ()
loadImage () Use load instead

Drawing

draw ()

Texture

update ()
getTextureReference () Use getTexture
bind ()
unbind ()

Pixel Getters

getPixelsRef () Use getPixels() instead

Pixel Setters

Modifiers

resize ()
crop ()
mirror ()

Anchor

Saving

save ()
saveImage () Use save instead

Operators

Attributes

width variable
height variable
bpp variable
type variable

Functions

draw ()

ofPixels_class

template<typename PixelType>
class ofPixels_< PixelType >

A class representing a collection of pixels.

Construction And Allocation

clear ()

Set Pixel Data

set ()
swap ()

Modify Existing Data

crop ()
cropTo ()
mirror ()
resize ()
swapRgb ()

Pixels Access

getData ()
getPixels () Use getData instead
() Accessing pixels as unsigned char*, instead use ofPixels or getPixels().getData() if you are really trying to access the raw data

Getters

size ()

Setters

Iterator

iterator typedef
const_iterator typedef
begin ()
end ()
begin ()
end ()
rbegin ()
rbegin ()
rend ()

ofColor_class

template<typename T>
class ofColor_< T >

ofColor represents a color in openFrameworks. Colors are usually defined by specifying a red, green, and blue component (RGB), and a transparency (alpha) component. You can also specify colors using hue, saturation, and brightness (HSB).

For example:

// Set red, component by component
red.r=255;
red.g=0;
red.b=0;
// Draw color is now red.
// Shorter notation is also possible.
ofColor green(0, 255, 0);
// Draw color is now green.
// ... or even shorter.
ofSetColor( ofColor(0, 0, ofRandom( 128, 255 ) );
// Draw color is now a random blue.

ofColor also enables a lot of extra functionality like using HSB instead of color spectrums, lerping or linearly interpolating between colors, and inverting colors, among other things.

ofColor is templated, which means that it has several different ways it can be created. These are probably best to leave as they are because there's already a few kinds typedefed for you. The default ofColor uses unsigned char values (0 to 255), but you can make an ofFloatColor if you want to work with floating point numbers between 0 and 1, or ofShortColor if you want to work with integers between 0 and 65,535.

Typedef PixelType Bit Depth Min. Value Max. Value
ofColor unsigned char 8 0 255
ofShortColorunsigned short 16 0 65535
ofFloatColorfloat varies 0.0 1.0

HSB

You're probably familiar with RGB colors already, but HSB is a big part of ofColor. It uses a hue value (for the standard ofColor the range for this value is between 0 and 255) to determine what the hue (the 'color' in the sense of a color in the rainbow) will be:

HSB

Approximate hues for some common colors:

  • Red: 0 (wrapped round from 255)
  • Orange: 25
  • Yellow: 42
  • Green: 85
  • Blue: 170
  • Purple: 205
  • Red: 255 (wraps round to 0)

Once you've selected a hue, you can use the saturation and brightness values to further refine the color. The saturation determines how much of the hue versus white is present and brightness determines how much hue versus black is present:

SB

In other words, saturation refers to the intensity of the color: high saturation means intense color, low saturation means washed out or black and white. Brightness refers to how light or dark the color is: high brightness means a bright color, low brightness means a dark color. If the brightness is 0 the resulting color will be black, regardless of the values of hue or saturation.

Template Parameters
PixelTypeThe data type used to represent a single pixel value.

Create an ofColor

fromHsb ()
fromHex ()

Data Accessors

Setters

set ()
setHex ()
setHue ()
setHsb ()

Modifiers

clamp ()
invert ()
lerp ()

Getters

getHex ()
getHue ()
getHsb ()
limit ()

Operators

operator<< friend
operator>> friend

Predefined Colors

A collection of static colors defined by name.

  These constants allow the user to access colors by name. For example, if using ofColor, one might set a color in the following way:

// myColor is now full white (255,255,255,255).

The list of colors is based upon the CSS names colors and can be viewed here.

white variable
gray variable
black variable
red variable
green variable
blue variable
cyan variable
magenta variable
yellow variable
aliceBlue variable
antiqueWhite variable
aqua variable
aquamarine variable
azure variable
beige variable
bisque variable
blanchedAlmond variable
blueViolet variable
brown variable
burlyWood variable
cadetBlue variable
chartreuse variable
chocolate variable
coral variable
cornflowerBlue variable
cornsilk variable
crimson variable
darkBlue variable
darkCyan variable
darkGoldenRod variable
darkGray variable
darkGrey variable
darkGreen variable
darkKhaki variable
darkMagenta variable
darkOliveGreen variable
darkorange variable
darkOrchid variable
darkRed variable
darkSalmon variable
darkSeaGreen variable
darkSlateBlue variable
darkSlateGray variable
darkSlateGrey variable
darkTurquoise variable
darkViolet variable
deepPink variable
deepSkyBlue variable
dimGray variable
dimGrey variable
dodgerBlue variable
fireBrick variable
floralWhite variable
forestGreen variable
fuchsia variable
gainsboro variable
ghostWhite variable
gold variable
goldenRod variable
grey variable
greenYellow variable
honeyDew variable
hotPink variable
indianRed variable
indigo variable
ivory variable
khaki variable
lavender variable
lavenderBlush variable
lawnGreen variable
lemonChiffon variable
lightBlue variable
lightCoral variable
lightCyan variable
lightGray variable
lightGrey variable
lightGreen variable
lightPink variable
lightSalmon variable
lightSeaGreen variable
lightSkyBlue variable
lightSlateGray variable
lightSlateGrey variable
lightSteelBlue variable
lightYellow variable
lime variable
limeGreen variable
linen variable
maroon variable
mediumAquaMarine variable
mediumBlue variable
mediumOrchid variable
mediumPurple variable
mediumSeaGreen variable
mediumSlateBlue variable
mediumTurquoise variable
mediumVioletRed variable
midnightBlue variable
mintCream variable
mistyRose variable
moccasin variable
navajoWhite variable
navy variable
oldLace variable
olive variable
oliveDrab variable
orange variable
orangeRed variable
orchid variable
paleGoldenRod variable
paleGreen variable
paleTurquoise variable
paleVioletRed variable
papayaWhip variable
peachPuff variable
peru variable
pink variable
plum variable
powderBlue variable
purple variable
rosyBrown variable
royalBlue variable
saddleBrown variable
salmon variable
sandyBrown variable
seaGreen variable
seaShell variable
sienna variable
silver variable
skyBlue variable
slateBlue variable
slateGray variable
slateGrey variable
snow variable
springGreen variable
steelBlue variable
blueSteel variable
tan variable
teal variable
thistle variable
tomato variable
turquoise variable
violet variable
wheat variable
whiteSmoke variable
yellowGreen variable

Attributes

r variable
g variable
b variable
a variable
v variable

ofBaseDrawsclass

Functions

draw ()

ofBaseUpdatesclass

An abstract class representing an object that can be updated.

Functions

ofBaseHasTextureclass

An abstract class representing an object that can have an ofTexture.

Functions

ofBaseHasTexturePlanesclass

An abstract class representing an object that ofTexture planes.

Functions

ofAbstractHasPixelsclass

An abstract class representing an object that has pixels.

This empty class primarily exists to allow templated subclasses of different types to be stored as raw or shared pointers in collections such as std::vector.

Example:

std::vector<ofAbstractHasPixels> pixelProviders;
ofPixels pixels;
ofFloatPixels floatPixels;
ofShortPixels shortPixels;
// ...
pixelProviders.push_back(&pixels);
pixelProviders.push_back(&floatPixels);
pixelProviders.push_back(&shortPixels);

Functions

ofBaseHasPixels_class

template<typename T>
class ofBaseHasPixels_< T >

A base class represeting an object that has pixels.

Template Parameters
TThe pixel data type.

Functions

ofAbstractImageclass

An abstract class representing an image.

This empty class primarily exists to allow templated subclasses of different types to be stored as raw or shared pointers in collections such as std::vector.

Example:

std::vector<ofAbstractImage*> imageProviders;
ofImage image;
ofFloatImage floatImage;
ofShortImage shortImage;
// ...
imageProviders.push_back(&image);
imageProviders.push_back(&floatImage);
imageProviders.push_back(&shortImage);

Functions

draw ()

ofBaseImage_class

template<typename T>
class ofBaseImage_< T >

A base class represeting an image.

Template Parameters
TThe pixel data type.

Functions

draw ()

ofBaseSoundInputclass

A base class representing a sound input stream.

Functions

audioIn ()

ofBaseSoundOutputclass

A base class representing a sound output stream.

Functions

ofBaseVideoclass

A base class representing a video source.

Functions

update ()

ofBaseVideoDrawsclass

A base class representing a drawable video source.

Functions

close ()
update ()
draw ()

ofBaseVideoGrabberclass

A base class representing a video device such as a camera.

Functions

setup ()
close ()
update ()

ofBaseVideoPlayerclass

A base class representing a video player.

Functions

load ()
close ()
update ()

ofBaseRendererclass

Functions

getType ()
draw ()
scale ()
rotate ()
rotateX ()
rotateY ()
rotateZ ()
rotate ()
bind ()
unbind ()
clear ()
drawBox ()

ofBaseGLRendererclass

Functions

draw ()
draw ()
bind ()
unbind ()
getType ()
update ()
draw ()
popView ()
scale ()
rotate ()
rotateX ()
rotateY ()
rotateZ ()
bind ()
unbind ()
clear ()
getPath ()
drawBox ()

ofBaseSerializerclass

Functions

ofBaseFileSerializerclass

Functions

load ()
save ()

ofBaseURLFileLoaderclass

Functions

get ()
saveTo ()
remove ()
clear ()
stop ()

ofBaseMaterialclass

Functions

begin ()
end ()