jjPAL class JJ2+
A palette of 256 colors
Colors are edited through color or the fill, gradient and copy methods; nothing changes on screen until apply() puts the palette into use. jjPalette holds the palette in use, jjBackupPalette the original one of the level. A new palette is all black.
Constructors
Functions
- void apply() const
- Makes this palette the one the game draws with
- void copyFrom(uint8 start, uint8 length, uint8 start2, const jjPAL&in source, float opacity = 1.0)
- Copies a range of colors from another palette
- void fill(uint8 red, uint8 green, uint8 blue, float opacity)
- Fills the whole palette with a color
- void fill(uint8 red, uint8 green, uint8 blue, uint8 start = 1, uint8 length = 254, float opacity = 1.0)
- Fills a range of the palette with a color
- void fill(jjPALCOLOR color, float opacity) C++
- Fills the whole palette with a color, see the overload taking components
- void fill(jjPALCOLOR color, uint8 start = 1, uint8 length = 254, float opacity = 1.0) C++
- Fills a range of the palette with a color, see the overload taking components
- uint8 findNearestColor(jjPALCOLOR color) const C++
- Returns the index of the palette entry closest to a color, any of the 256 entries can be returned
- const jjPALCOLOR& get_color(uint8 idx) const C++
- Returns the color at a palette index, read-only
- void gradient(uint8 red1, uint8 green1, uint8 blue1, uint8 red2, uint8 green2, uint8 blue2, uint8 start = 176, uint8 length = 32, float opacity = 1.0, bool inclusive = false)
- Writes a gradient between two colors into a range of the palette
- void gradient(jjPALCOLOR color1, jjPALCOLOR color2, uint8 start = 176, uint8 length = 32, float opacity = 1.0, bool inclusive = false) C++
- Writes a gradient between two colors into a range of the palette, see the overload taking components
- bool load(string&in filename)
- Loads the palette from a file and returns whether it succeeded
- void reset() C++
- Restores the original colors of the level, the same as assigning jjBackupPalette
Operators
Properties
- jjPALCOLOR color[uint8]
- The color at a palette index
Function documentation
void jjPAL:: copyFrom(uint8 start,
uint8 length,
uint8 start2,
const jjPAL&in source,
float opacity = 1.0)
Copies a range of colors from another palette
Copies length colors of source from index start2 to this palette from index start. With opacity below 1.0, they are only mixed into the existing colors.
void jjPAL:: fill(uint8 red,
uint8 green,
uint8 blue,
uint8 start = 1,
uint8 length = 254,
float opacity = 1.0)
Fills a range of the palette with a color
Replaces length entries from start, by default all but the first and the last one. With opacity below 1.0, the color is only mixed into the existing colors, tinting them.
void jjPAL:: gradient(uint8 red1,
uint8 green1,
uint8 blue1,
uint8 red2,
uint8 green2,
uint8 blue2,
uint8 start = 176,
uint8 length = 32,
float opacity = 1.0,
bool inclusive = false)
Writes a gradient between two colors into a range of the palette
Replaces length entries from start; the defaults cover the entries used by water and most textured backgrounds. When inclusive is false, the gradient stops one step short of the second color, otherwise the last entry is exactly the second color. With opacity below 1.0, the gradient is only mixed into the existing colors.
bool jjPAL:: load(string&in filename)
Loads the palette from a file and returns whether it succeeded
Accepts the palette of a tile set (.j2t), a Windows palette file (plain or in a RIFF container), or otherwise raw red, green and blue bytes for each entry. Entries the file doesn't contain keep their colors. Returns false only if the file can't be opened or read.
Property documentation
jjPALCOLOR jjPAL:: color[uint8]
The color at a palette index
Changes made to the returned color edit the palette directly; they show on screen once the palette is applied with apply().