|
OpenTTD Source
14.0-beta3
|
Go to the documentation of this file.
42 const uint PALETTE_BITS_MASK = ((1U <<
PALETTE_BITS) - 1) << PALETTE_SHIFT;
43 const uint PALETTE_BITS_OR = (1U << (PALETTE_SHIFT - 1));
46 using PaletteLookup = std::array<uint8_t, 1U << (
PALETTE_BITS * 3)>;
47 static PaletteLookup _palette_lookup{};
61 return (c & PALETTE_BITS_MASK) | PALETTE_BITS_OR;
75 int r = (int)col1.r - (
int)r2;
76 int g = (int)col1.g - (
int)g2;
77 int b = (int)col1.b - (
int)b2;
79 int avgr = (col1.r + r2) / 2;
80 return ((2 + (avgr / 256.0)) * r * r) + (4 * g * g) + ((2 + ((255 - avgr) / 256.0)) * b * b);
103 uint best_distance = UINT32_MAX;
108 best_distance = distance;
115 best_distance = distance;
131 uint32_t key = (r >> PALETTE_SHIFT) | (g >> PALETTE_SHIFT) <<
PALETTE_BITS | (b >> PALETTE_SHIFT) << (
PALETTE_BITS * 2);
133 return _palette_lookup[key];
136 void DoPaletteAnimations();
138 void GfxInitPalettes()
142 DoPaletteAnimations();
171 #define EXTR(p, q) (((uint16_t)(palette_animation_counter * (p)) * (q)) >> 16)
172 #define EXTR2(p, q) (((uint16_t)(~palette_animation_counter * (p)) * (q)) >> 16)
174 void DoPaletteAnimations()
179 static int palette_animation_counter = 0;
180 palette_animation_counter += 8;
186 const uint old_tc = palette_animation_counter;
190 palette_animation_counter = 0;
196 memcpy(old_val, palette_pos,
sizeof(old_val));
202 *palette_pos++ = s[j];
211 *palette_pos++ = s[j];
218 byte i = (palette_animation_counter >> 1) & 0x7F;
223 }
else if (i < 0x4A || i >= 0x75) {
236 }
else if (i < 0x4A || i >= 0x75) {
251 *palette_pos++ = s[j];
260 *palette_pos++ = s[j];
269 *palette_pos++ = s[j];
275 palette_animation_counter = old_tc;
294 uint sq1000_brightness = c.r * c.r * 299 + c.g * c.g * 587 + c.b * c.b * 114;
296 return sq1000_brightness < ((uint) threshold) * ((uint) threshold) * 1000 ? TC_WHITE : TC_BLACK;
int first_dirty
The first dirty element.
uint CrunchColour(uint c)
Reduce bits per channel to PALETTE_BITS, and place value in the middle of the reduced range.
byte landscape
the landscape we're currently in
@ PALETTE_ANIM_SIZE
number of animated colours
virtual Blitter::PaletteAnimation UsePaletteAnimation()=0
Check if the blitter uses palette animation at all.
std::mutex lock
synchronization for playback status fields
How all blitters should look like.
static const Palette _palette
Colour palette (DOS)
bool CopyPalette(Palette &local_palette, bool force_copy)
Copy the current palette if the palette was updated.
const uint PALETTE_BITS
PALETTE_BITS reduces the bits-per-channel of 32bpp graphics data to allow faster palette lookups from...
TextColour
Colour of the strings, see _string_colourmap in table/string_colours.h or docs/ottd-colourtext-palett...
const uint8_t PALETTE_INDEX_CC_END
Palette index of end of company colour remap area.
static const uint EPV_CYCLES_FIZZY_DRINK
length of the fizzy drinks animation
static std::recursive_mutex _palette_mutex
To coordinate access to _cur_palette.
byte _colour_gradient[COLOUR_END][8]
All 16 colour gradients 8 colours per gradient from darkest (0) to lightest (7)
GameCreationSettings game_creation
settings used during the creation of a game (map)
static uint CalculateColourDistance(const Colour &col1, int r2, int g2, int b2)
Calculate distance between two colours.
static const ExtraPaletteValues _extra_palette_values
Actual palette animation tables.
Colour palette[256]
Current palette. Entry 0 has to be always fully transparent!
const uint8_t PALETTE_INDEX_START
Palette index of start of defined palette.
GameSettings _settings_game
Game settings of a running game or the scenario editor.
const uint8_t PALETTE_INDEX_END
Palette index of end of defined palette.
static Blitter * GetCurrentBlitter()
Get the current active blitter (always set by calling SelectBlitter).
static const uint EPV_CYCLES_OIL_REFINERY
length of the oil refinery's fire animation
static uint8_t FindNearestColourIndex(uint8_t r, uint8_t g, uint8_t b)
Find nearest colour palette index for a 32bpp pixel.
int count_dirty
The number of dirty elements.
@ PALETTE_ANIM_START
Index in the _palettes array from which all animations are taking places (table/palettes....
Structure to access the alpha, red, green, and blue channels from a 32 bit number.
uint8_t GetNearestColourIndex(uint8_t r, uint8_t g, uint8_t b)
Get nearest colour palette index from an RGB colour.
static const uint EPV_CYCLES_LIGHTHOUSE
length of the lighthouse/stadium animation
const uint8_t PALETTE_INDEX_CC_START
Palette index of start of company colour remap area.
@ PALETTE_ANIMATION_NONE
No palette animation.
Palette _cur_palette
Current palette.
static const uint EPV_CYCLES_DARK_WATER
Description of the length of the palette cycle animations.
Information about the currently used palette.
static const uint EPV_CYCLES_GLITTER_WATER
length of the glittery water animation
TextColour GetContrastColour(uint8_t background, uint8_t threshold)
Determine a contrasty text colour for a coloured background.