![]() |
Public API Reference |
A simple color gradient. More...
#include <ivaria/gradient.h>
Public Member Functions | |
| virtual void | Clear ()=0 |
| Clear all shades. | |
| virtual csPtr< iGradientShades > | GetShades ()=0 |
| Get the array of shades. | |
| virtual bool | Render (csRGBcolor *pal, size_t count, float begin=0.0f, float end=1.0f) const =0 |
| Interpolate the colors over a part of the gradient. | |
| virtual bool | Render (csRGBpixel *pal, size_t count, float begin=0.0f, float end=1.0f) const =0 |
| Interpolate the colors over a part of the gradient. | |
| virtual void | AddShade (const csGradientShade &shade)=0 |
| Add a shade. | |
| virtual void | AddShade (const csColor4 &color, float position)=0 |
| Add a shade. | |
| virtual void | AddShade (const csColor4 &left, const csColor4 &right, float position)=0 |
| Add a shade. | |
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.
This interface is implemented by csGradient.
Examples:
csRef<iGradient> grad; // Rainbow-ish grad->AddShade (csColor4 (1.0f, 0.0f, 0.0f, 1.0f), 0.0f); grad->AddShade (csColor4 (1.0f, 1.0f, 0.0f, 1.0f), 0.2f); grad->AddShade (csColor4 (0.0f, 1.0f, 0.0f, 1.0f), 0.4f); grad->AddShade (csColor4 (0.0f, 1.0f, 1.0f, 1.0f), 0.6f); grad->AddShade (csColor4 (0.0f, 0.0f, 1.0f, 1.0f), 0.8f); grad->AddShade (csColor4 (1.0f, 0.0f, 1.0f, 1.0f), 1.0f); // German flag grad->Clear (); grad->AddShade (csColor4 (0.0f, 0.0f, 0.0f, 1.0f), 0.0f); grad->AddShade (csColor4 (0.0f, 0.0f, 0.0f, 1.0f), csColor4 (1.0f, 0.0f, 0.0f, 1.0f), 0.33f); grad->AddShade (csColor4 (1.0f, 0.0f, 0.0f, 1.0f), csColor4 (1.0f, 1.0f, 0.0f, 1.0f), 0.66f); grad->AddShade (csColor4 (1.0f, 1.0f, 0.0f, 1.0f), 1.0f);
Definition at line 127 of file gradient.h.
| virtual void iGradient::AddShade | ( | const csGradientShade & | shade | ) | [pure virtual] |
Add a shade.
Implemented in csGradient.
| virtual void iGradient::AddShade | ( | const csColor4 & | color, |
| float | position | ||
| ) | [pure virtual] |
Add a shade.
Implemented in csGradient.
| virtual void iGradient::AddShade | ( | const csColor4 & | left, |
| const csColor4 & | right, | ||
| float | position | ||
| ) | [pure virtual] |
Add a shade.
Implemented in csGradient.
| virtual void iGradient::Clear | ( | ) | [pure virtual] |
Clear all shades.
Implemented in csGradient.
| virtual csPtr<iGradientShades> iGradient::GetShades | ( | ) | [pure virtual] |
Get the array of shades.
Implemented in csGradient.
| virtual bool iGradient::Render | ( | csRGBcolor * | pal, |
| size_t | count, | ||
| float | begin = 0.0f, |
||
| float | end = 1.0f |
||
| ) | const [pure virtual] |
Interpolate the colors over a part of the gradient.
| pal | Array of csRGBcolor the gradient should be rendered to. |
| count | Number of palette entries to render. |
| begin | Start position. Can be anywhere in the gradient. |
| end | End position. Can be anywhere in the gradient. |
begin doesn't have to be smaller than end. begin and end can both lie completely 'outside' the gradient (i.e. both smaller/large than the first resp. last shade's position.) Implemented in csGradient.
| virtual bool iGradient::Render | ( | csRGBpixel * | pal, |
| size_t | count, | ||
| float | begin = 0.0f, |
||
| float | end = 1.0f |
||
| ) | const [pure virtual] |
Interpolate the colors over a part of the gradient.
| pal | Array of csRGBpixel the gradient should be rendered to. |
| count | Number of palette entries to render. |
| begin | Start position. Can be anywhere in the gradient. |
| end | End position. Can be anywhere in the gradient. |
begin doesn't have to be smaller than end. begin and end can both lie completely 'outside' the gradient (i.e. both smaller/large than the first resp. last shade's position.) Implemented in csGradient.