v1.1.0
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Modules Pages
Public Member Functions | Static Public Member Functions | Public Attributes | List of all members
Sifteo::RGB565 Struct Reference

Represents a 16-bit 5:6:5 color, the native format used by our display. More...

#include <sifteo/video/color.h>

Public Member Functions

uint8_t blue () const
 Return the color's blue component, extended to 8 bits.
 
uint8_t blue5 () const
 Return the color's blue component, as a 5-bit value.
 
uint8_t green () const
 Return the color's green component, extended to 8 bits.
 
uint8_t green6 () const
 Return the color's green component, as a 6-bit value.
 
RGB565 lerp (RGB565 other, uint8_t alpha) const
 Linear interpolation between this color and another color. More...
 
bool operator!= (const RGB565 &other) const
 Exact inequality test.
 
bool operator== (const RGB565 &other) const
 Exact equality test.
 
uint32_t packedRGB () const
 Return the color as a packed 24-bit RGB value. More...
 
uint8_t red () const
 Return the color's red component, extended to 8 bits.
 
uint8_t red5 () const
 Return the color's red component, as a 5-bit value.
 

Static Public Member Functions

static RGB565 from565 (uint8_t r, uint8_t g, uint8_t b)
 Create an RGB565 color from a 5-6-5-bit RGB color, with each component specified separately.
 
static RGB565 fromRGB (uint8_t r, uint8_t g, uint8_t b)
 Create an RGB565 color from an 8-bit RGB color. We accurately round to the nearest representable 16-bit color.
 
static RGB565 fromRGB (float r, float g, float b)
 Create an RGB565 color from a floating point RGB color. We accurately round to the nearest representable 16-bit color.
 
static RGB565 fromRGB (uint32_t rgb)
 Create an RGB565 color from a packed-pixel 24-bit RGB color. More...
 

Public Attributes

uint16_t value
 The raw color value, as a 16-bit integer.
 

Detailed Description

Represents a 16-bit 5:6:5 color, the native format used by our display.

This is a C++ Plain Old Data (POD) type.

RGB565 colors can be converted to and from 8-bit RGB, and this class can perform simple color blending.

Member Function Documentation

static RGB565 Sifteo::RGB565::fromRGB ( uint32_t  rgb)
inlinestatic

Create an RGB565 color from a packed-pixel 24-bit RGB color.

Blue is in the least significant byte, making this convenient for specifying colors in the common hexadecimal format 0xRRGGBB.

RGB565 Sifteo::RGB565::lerp ( RGB565  other,
uint8_t  alpha 
) const
inline

Linear interpolation between this color and another color.

When alpha=255, this returns the "other" color. When alpha=0, we return this color. Values in-between will result in a correspondingly blended color.

uint32_t Sifteo::RGB565::packedRGB ( ) const
inline

Return the color as a packed 24-bit RGB value.

Blue is in the least significant byte. The resulting color, in hexadecimal, has the form 0xRRGGBB.


The documentation for this struct was generated from the following file: