colors 0.0.2
A color library that implement CSS colors.
To use this package, run the following command in your project's root directory:
Manual usage
Put the following dependency into your project's dependences section:
Colors
colors
DUB package is a CSS color parsing libraries.
It defines basic types for colors, and a monomorphic Color
type to
use as interchange.
The problem is that screens and CSS now support the P3 colorspace, the end-goal is to be ready for more conversions than just staying sRGB forever. Color will be able to "do it all", in the future.
This is a work in progress. Only sRGB supported for now.
Current features
- 🎨
color()
function to parse a CSS color string. - 🎨
rgb()
andrgba()
functions, return aColor
- 🎨
hsl()
andhsla()
functions, return aColor
- 🎨
Color.toRGBA8()
to get a 8-bit sRGB quadruplet - 🎨
Color.toRGBAf()
to get a 32-bit float sRGB quadruplet - 🎨
nothrow @nogc @safe
- 🎨 See
test-suite/
for exact syntax supported, the goal is to follow CSS recommendations.
Tip: Parsing a color string
import colors;
// Quick way:
Color c = color("red");
Color c = Color("blue"); // also works
// More correct way:
string err;
if (!parseCSSColor(str, c, err))
throw new Exception(err);
Making it useful
import std.stdio;
import colors;
void main()
{
RGBA8 c = color("coral").toRGBA8;
writefln("c is %s,%s,%s,%s", c.r, c.g, c.b, c.a);
}
- Registered by ponce
- 0.0.2 released 2 months ago
- AuburnSounds/colors
- BSL-1.0
- Dependencies:
- none
- Versions:
-
0.0.3 2024-Oct-11 0.0.2 2024-Oct-11 0.0.1 2024-Oct-11 ~master 2024-Oct-14 - Download Stats:
-
-
2 downloads today
-
7 downloads this week
-
30 downloads this month
-
48 downloads total
-
- Score:
- 1.1
- Short URL:
- colors.dub.pm