mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 06:37:35 +00:00
AK: Rename the common integer typedefs to make it obvious what they are.
These types can be picked up by including <AK/Types.h>: * u8, u16, u32, u64 (unsigned) * i8, i16, i32, i64 (signed)
This commit is contained in:
parent
c4c4bbc5ba
commit
27f699ef0c
208 changed files with 1603 additions and 1621 deletions
|
@ -3,9 +3,9 @@
|
|||
#include <AK/AKString.h>
|
||||
#include <AK/Types.h>
|
||||
|
||||
typedef dword RGBA32;
|
||||
typedef u32 RGBA32;
|
||||
|
||||
inline constexpr dword make_rgb(byte r, byte g, byte b)
|
||||
inline constexpr u32 make_rgb(u8 r, u8 g, u8 b)
|
||||
{
|
||||
return ((r << 16) | (g << 8) | b);
|
||||
}
|
||||
|
@ -36,11 +36,11 @@ public:
|
|||
|
||||
Color() {}
|
||||
Color(NamedColor);
|
||||
Color(byte r, byte g, byte b)
|
||||
Color(u8 r, u8 g, u8 b)
|
||||
: m_value(0xff000000 | (r << 16) | (g << 8) | b)
|
||||
{
|
||||
}
|
||||
Color(byte r, byte g, byte b, byte a)
|
||||
Color(u8 r, u8 g, u8 b, u8 a)
|
||||
: m_value((a << 24) | (r << 16) | (g << 8) | b)
|
||||
{
|
||||
}
|
||||
|
@ -48,36 +48,36 @@ public:
|
|||
static Color from_rgb(unsigned rgb) { return Color(rgb | 0xff000000); }
|
||||
static Color from_rgba(unsigned rgba) { return Color(rgba); }
|
||||
|
||||
byte red() const { return (m_value >> 16) & 0xff; }
|
||||
byte green() const { return (m_value >> 8) & 0xff; }
|
||||
byte blue() const { return m_value & 0xff; }
|
||||
byte alpha() const { return (m_value >> 24) & 0xff; }
|
||||
u8 red() const { return (m_value >> 16) & 0xff; }
|
||||
u8 green() const { return (m_value >> 8) & 0xff; }
|
||||
u8 blue() const { return m_value & 0xff; }
|
||||
u8 alpha() const { return (m_value >> 24) & 0xff; }
|
||||
|
||||
void set_alpha(byte value)
|
||||
void set_alpha(u8 value)
|
||||
{
|
||||
m_value &= 0x00ffffff;
|
||||
m_value |= value << 24;
|
||||
}
|
||||
|
||||
void set_red(byte value)
|
||||
void set_red(u8 value)
|
||||
{
|
||||
m_value &= 0xff00ffff;
|
||||
m_value |= value << 16;
|
||||
}
|
||||
|
||||
void set_green(byte value)
|
||||
void set_green(u8 value)
|
||||
{
|
||||
m_value &= 0xffff00ff;
|
||||
m_value |= value << 8;
|
||||
}
|
||||
|
||||
void set_blue(byte value)
|
||||
void set_blue(u8 value)
|
||||
{
|
||||
m_value &= 0xffffff00;
|
||||
m_value |= value;
|
||||
}
|
||||
|
||||
Color with_alpha(byte alpha)
|
||||
Color with_alpha(u8 alpha)
|
||||
{
|
||||
return Color((m_value & 0x00ffffff) | alpha << 24);
|
||||
}
|
||||
|
@ -91,10 +91,10 @@ public:
|
|||
return *this;
|
||||
|
||||
int d = 255 * (alpha() + source.alpha()) - alpha() * source.alpha();
|
||||
byte r = (red() * alpha() * (255 - source.alpha()) + 255 * source.alpha() * source.red()) / d;
|
||||
byte g = (green() * alpha() * (255 - source.alpha()) + 255 * source.alpha() * source.green()) / d;
|
||||
byte b = (blue() * alpha() * (255 - source.alpha()) + 255 * source.alpha() * source.blue()) / d;
|
||||
byte a = d / 255;
|
||||
u8 r = (red() * alpha() * (255 - source.alpha()) + 255 * source.alpha() * source.red()) / d;
|
||||
u8 g = (green() * alpha() * (255 - source.alpha()) + 255 * source.alpha() * source.green()) / d;
|
||||
u8 b = (blue() * alpha() * (255 - source.alpha()) + 255 * source.alpha() * source.blue()) / d;
|
||||
u8 a = d / 255;
|
||||
return Color(r, g, b, a);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue