mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 20:47:45 +00:00
SharedGraphics: Add Color::to_string().
This generates a string in the format "rgba(%d, %d, %d, %d)".
This commit is contained in:
parent
c24d4b07db
commit
f4b8e4966f
2 changed files with 8 additions and 0 deletions
|
@ -25,3 +25,8 @@ Color::Color(NamedColor named)
|
||||||
|
|
||||||
m_value = 0xff000000 | (rgb.r << 16) | (rgb.g << 8) | rgb.b;
|
m_value = 0xff000000 | (rgb.r << 16) | (rgb.g << 8) | rgb.b;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String Color::to_string() const
|
||||||
|
{
|
||||||
|
return String::format("rgba(%d, %d, %d, %d)", red(), green(), blue(), alpha());
|
||||||
|
}
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <AK/AKString.h>
|
||||||
#include <AK/Types.h>
|
#include <AK/Types.h>
|
||||||
|
|
||||||
typedef dword RGBA32;
|
typedef dword RGBA32;
|
||||||
|
@ -66,6 +67,8 @@ public:
|
||||||
|
|
||||||
RGBA32 value() const { return m_value; }
|
RGBA32 value() const { return m_value; }
|
||||||
|
|
||||||
|
String to_string() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
explicit Color(RGBA32 rgba) : m_value(rgba) { }
|
explicit Color(RGBA32 rgba) : m_value(rgba) { }
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue