arsd.color

Members

Classes

IndexedImage
class IndexedImage

An image that consists of indexes into a color palette. Use getAsTrueColorImage() if you don't care about palettes

TrueColorImage
class TrueColorImage

An RGBA array of image data. Use the free function quantize() to convert to an IndexedImage

Functions

darken
Color darken(Color c, real percentage)

.

extremify
Color extremify(Color c, real percentage)

the opposite of moderate. Make darks darker and lights lighter

findNearestColor
ubyte findNearestColor(in Color[] palette, in Color pixel)

Finds the best match for pixel in palette (currently by checking for minimum euclidean distance in rgb colorspace)

floydSteinbergDither
void floydSteinbergDither(IndexedImage img, in TrueColorImage original)

Dithers img in place to look more like original.

fromHsl
Color fromHsl(real[3] hsl)

Converts hsl to rgb

fromHsl
Color fromHsl(real h, real s, real l, real a = 255)

Converts hsl to rgb

lighten
Color lighten(Color c, real percentage)

.

makeTextColor
Color makeTextColor(Color c)

Try to determine a text color - either white or black - based on the input

moderate
Color moderate(Color c, real percentage)

for light colors, call darken. for dark colors, call lighten. The goal: get toward center grey.

oppositeLightness
Color oppositeLightness(Color c)

Move around the lightness wheel, trying not to break on moderate things

quantize
IndexedImage quantize(in TrueColorImage img, Color[] palette = null, in int maxColors = 256)

Converts true color to an indexed image. It uses palette as the starting point, adding entries until maxColors as needed. If palette is null, it creates a whole new palette.

toHsl
real[3] toHsl(Color c, bool useWeightedLightness = false)

Converts an RGB color into an HSL triplet. useWeightedLightness will 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 is false, it just does average of the rgb.

Interfaces

MemoryImage
interface MemoryImage

This provides two image classes and a bunch of functions that work on them.

Structs

Color
struct Color

Represents an RGBA color

Meta