csGradient Class Reference
A simple color gradient. More...
#include <csgfx/gradient.h>
Public Member Functions | |
void | AddShade (csGradientShade shade) |
Add a shade. | |
void | Clear () |
Clear all shades. | |
csGradient (csColor first, csColor last) | |
Construct with first at position 0 and last at 1. | |
csGradient () | |
Construct an empty gradient. | |
const csArray< csGradientShade > & | GetShades () const |
Get the array of shades. | |
bool | Render (csRGBcolor *pal, size_t count, float begin=0.0f, float end=1.0f) const |
Interpolate the colors over a part of the gradient. | |
Protected Attributes | |
csArray< csGradientShade > | shades |
The entries in this gradient. |
Detailed Description
A simple color gradient.If you ever have worked with an image creation/manipulation program with a slightly higher niveau than Windows Paint then you probably know what this is.
Colors(here called 'shades') can be placed at arbitrary positions; although commonly a range of [0;1] is used, negative positions and positions larger than 1 are supported.
Shades contain actually two colors, a 'left' and 'right' one. You can think of this as, when approaching from one side, you'll get closer and closer to the respective color. If you step over a shade, you have the other color, but you're getting farther and farther from it (and towards the next color) when moving on. This feature can be used for sharp transitions; for smooth ones they are simply set to the same value.
Examples:
csGradient grad; // Rainbow-ish grad.AddShade (csGradientShade (csColor (1.0f, 0.0f, 0.0f), 0.0f))); grad.AddShade (csGradientShade (csColor (1.0f, 1.0f, 0.0f), 0.2f))); grad.AddShade (csGradientShade (csColor (0.0f, 1.0f, 0.0f), 0.4f))); grad.AddShade (csGradientShade (csColor (0.0f, 1.0f, 1.0f), 0.6f))); grad.AddShade (csGradientShade (csColor (0.0f, 0.0f, 1.0f), 0.8f))); grad.AddShade (csGradientShade (csColor (1.0f, 0.0f, 1.0f), 1.0f))); // German flag grad.Clear (); grad.AddShade (csGradientShade (csColor (0.0f, 0.0f, 0.0f), 0.0f))); grad.AddShade (csGradientShade (csColor (0.0f, 0.0f, 0.0f), csGradientShade (csColor (1.0f, 0.0f, 0.0f) 0.33f))); grad.AddShade (csGradientShade (csColor (1.0f, 0.0f, 0.0f), csGradientShade (csColor (1.0f, 1.0f, 0.0f) 0.66f))); grad.AddShade (csGradientShade (csColor (1.0f, 1.0f, 0.0f), 1.0f)));
- Todo:
- More shade management (e.g.
Definition at line 96 of file gradient.h.
Constructor & Destructor Documentation
|
Construct an empty gradient.
|
|
Construct with
|
Member Function Documentation
|
Add a shade.
|
|
Clear all shades.
|
|
Get the array of shades.
Definition at line 133 of file gradient.h. |
|
Interpolate the colors over a part of the gradient.
|
Member Data Documentation
|
The entries in this gradient.
Definition at line 100 of file gradient.h. |
The documentation for this class was generated from the following file:
- csgfx/gradient.h
Generated for Crystal Space by doxygen 1.4.4