arsd.color
-
Declaration
structColor;Represents an RGBA color
-
Declaration
ubyte[4]components;[r, g, b, a]
Discussion
The color
componentsare available as a static array, individual bytes, and a uint inside this union. Since it is anonymous, you can use the inner members' names directly. -
Declaration
ubyter;red
Discussion
Holder for rgba individual components. The color components are available as a static array, individual bytes, and a uint inside this union. Since it is anonymous, you can use the inner members' names directly.
-
Declaration
ubyteg;green
Discussion
Holder for rgba individual components. The color components are available as a static array, individual bytes, and a uint inside this union. Since it is anonymous, you can use the inner members' names directly.
-
Declaration
ubyteb;blue
Discussion
Holder for rgba individual components. The color components are available as a static array, individual bytes, and a uint inside this union. Since it is anonymous, you can use the inner members' names directly.
-
Declaration
ubytea;alpha. 255 == opaque
Discussion
Holder for rgba individual components. The color components are available as
astatic array, individual bytes, andauint inside this union. Since it is anonymous, you can use the inner members' names directly. -
Declaration
uintasUint;The components as a single 32 bit value (beware of endian issues!)
Discussion
The color components are available as a static array, individual bytes, and a uint inside this union. Since it is anonymous, you can use the inner members' names directly.
-
Declaration
static pure nothrow @safe ColorfromIntegers(intred, intgreen, intblue, intalpha= 255);Like the constructor, but this makes sure they are in range before casting. If they are out of range, it saturates: anything less than zero becomes zero and anything greater than 255 becomes 255.
-
Declaration
pure nothrow @nogc @safe this(intred, intgreen, intblue, intalpha= 255);Construct a color with the given values. They should be in range 0 <= x <= 255, where 255 is maximum intensity and 0 is minimum intensity.
-
Declaration
static pure nothrow @nogc @safe Colortransparent();
static pure nothrow @nogc @safe Colorwhite();
static pure nothrow @nogc @safe Colorblack();
static pure nothrow @nogc @safe Colorred();
static pure nothrow @nogc @safe Colorgreen();
static pure nothrow @nogc @safe Colorblue();
static pure nothrow @nogc @safe Coloryellow();
static pure nothrow @nogc @safe Colorteal();
static pure nothrow @nogc @safe Colorpurple();Static convenience functions for common color names
-
Declaration
ColortoBW()();Return black-and-white color
-
Declaration
const @safe stringtoCssString();Makes a string that matches CSS syntax for websites
-
Declaration
const @safe stringtoString();Makes a hex string RRGGBBAA (aa only present if it is not 255)
-
Declaration
const @safe stringtoRgbaHexString();returns RRGGBBAA, even if a== 255
-
Declaration
static @safe ColorfromNameString(strings);Gets a color by name, iff the name is one of the static members listed above
-
Declaration
static @safe ColorfromString(strings);Reads a CSS style string to get the color. Understands #rrggbb, rgba(), hsl(), and rrggbbaa
-
Declaration
static @safe ColorfromHsl(realh, reals, reall);from hsl
-
-
Declaration
@safe ColorfromHsl(real[3]hsl);Converts
hslto rgb -
Declaration
@safe ColorfromHsl(realh, reals, reall, reala= 255);Converts hsl to rgb
-
Declaration
@safe real[3]toHsl(Colorc, booluseWeightedLightness= false);Converts an RGB color into an HSL triplet.
useWeightedLightnesswill try to get a better value for luminosity for the human eye, which is more sensitive to green than red and more to red than blue. If it isfalse, it just does average of the rgb. -
Declaration
@safe Colorlighten(Colorc, realpercentage);.
-
Declaration
@safe Colordarken(Colorc, realpercentage);.
-
Declaration
@safe Colormoderate(Colorc, realpercentage);for light colors, call darken. for dark colors, call lighten.
Discussion
The goal: get toward center grey.
-
Declaration
@safe Colorextremify(Colorc, realpercentage);the opposite of moderate. Make darks darker and lights lighter
-
Declaration
@safe ColoroppositeLightness(Colorc);Move around the lightness wheel, trying not to break on moderate things
-
Declaration
@safe ColormakeTextColor(Colorc);Try to determine a text color - either white or black - based on the input
-
Declaration
@safe ColorrotateHue(Colorc, realdegrees); -
Declaration
@safe ColorsetHue(Colorc, realhue); -
Declaration
@safe Colordesaturate(Colorc, realpercentage); -
Declaration
@safe Colorsaturate(Colorc, realpercentage); -
Declaration
@safe ColorsetSaturation(Colorc, realsaturation); -
Declaration
@safe ubyteunalpha(ubytecolorYouHave, floatalpha, ubytebackgroundColor); -
Declaration
@safe ubytemakeAlpha(ubytecolorYouHave, ubytebackgroundColor); -
Declaration
@safe ColorcolorFromString(strings); -
Declaration
interfaceMemoryImage;This provides two image classes and a bunch of functions that work on them.
Discussion
Why are they separate classes? I think the operations on the two of them are necessarily different. There's a whole bunch of operations that only really work on truecolor (blurs, gradients), and a few that only work on indexed images (palette swaps). Even putpixel is pretty different. On indexed, it is a palette entry's index number. On truecolor, it is the actual color. A greyscale image is the weird thing in the middle. It is truecolor, but fits in the same size as indexed. Still, I'd say it is a specialization of truecolor. There is a subset that works on both An image in memory
-
Declaration
abstract @safe TrueColorImagegetAsTrueColorImage();gets it as a TrueColorImage. May return this or may do a conversion and return a new image
-
Declaration
abstract const @safe intwidth();Image
width, in pixels -
Declaration
abstract const @safe intheight();Image
height, in pixels -
Declaration
abstract const @safe ColorgetPixel(intx, inty);Get image pixel. Slow, but returns valid RGBA color (completely transparent for off-image pixels).
-
Declaration
abstract @safe voidsetPixel(intx, inty, in Colorclr);Set image pixel.
-
Declaration
@trusted MemoryImagefromImage(T : const(char)[])(Tfilename);Load image from file. This will import arsd.png and arsd.jpeg to do the actual work, and cost nothing if you don't use it.
-
-
Declaration
classIndexedImage: arsd.color.MemoryImage;An image that consists of indexes into a color palette. Use [getAsTrueColorImage]() if you don't care about palettes
-
Declaration
Color[]palette;.
-
Declaration
ubyte[]data;the
dataas indexes into the palette. Stored left to right, top to bottom, no padding. -
Declaration
const @safe intwidth();.
-
Declaration
const @safe intheight();.
-
Declaration
@safe this(intw, inth);.
-
Declaration
@safe TrueColorImagegetAsTrueColorImage();returns a new image
-
Declaration
const @safe TrueColorImageconvertToTrueColor();Creates a new TrueColorImage based on this data
-
Declaration
@safe ubytegetOrAddColor(Colorc);Gets an exact match, if possible, adds if not. See also: the findNearestColor free function.
-
Declaration
const @safe intnumColors();Number of colors currently in the palette (note: palette entries are not necessarily used in the image data)
-
Declaration
@safe ubyteaddColor(Colorc);Adds an entry to the palette, returning its inded
-
-
Declaration
classTrueColorImage: arsd.color.MemoryImage;An RGBA array of image data. Use the free function quantize() to convert to an IndexedImage
-
Declaration
structData; -
Declaration
DataimageData;.
-
Declaration
const @safe intwidth();.
-
Declaration
const @safe intheight();.
-
Declaration
@safe this(intw, inth);.
-
Declaration
@safe this(intw, inth, ubyte[]data);Creates with existing
data. Thedatapointer is stored here. -
Declaration
@safe TrueColorImagegetAsTrueColorImage();Returns this
-
-
Declaration
@safe IndexedImagequantize(in TrueColorImageimg, Color[]palette= null, in intmaxColors= 256);Converts
truecolor to an indexed image. It usespaletteas the starting point, adding entriesDiscussion
until
maxColorsas needed. Ifpaletteisnull, it creates a whole newpalette. After quantizing the image, it applies a dithering algorithm. This is not written for speed. -
Declaration
@safe ubytefindNearestColor(in Color[]palette, in Colorpixel);Finds the best match for
pixelinpalette(currently by checking for minimum euclidean distance in rgb colorspace) -
Declaration
@safe voidfloydSteinbergDither(IndexedImageimg, in TrueColorImageoriginal);Dithers
imgin place to look more likeoriginal. -
Declaration
structPoint; -
Declaration
structSize; -
Declaration
structRectangle;