Skip to content

Latest commit

 

History

History

orx-color

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 

orx-color

Tools to work with color

Color presets

orx-color adds an extensive list of preset colors to ColorRGBa. Check sources for a listing of the preset colors.

Color histograms

orx-color comes with tools to calculate color histograms for images.

val histogram = calculateHistogramRGB(image)
val colors = histogram.sortedColors()

Color sequences

Easy ways of creating blends between colors.

Using the rangeTo operator:

for (c in ColorRGBa.PINK..ColorRGBa.BLUE.toHSVa() blend 10) {
    drawer.fill = c
    drawer.rectangle(0.0, 0.0, 40.0, 40.0)
    drawer.translate(0.0, 40.0)
}

Or blends for multiple color stops using colorSequence. Blending takes place in the colorspace of the input arguments.

val cs = colorSequence(0.0 to ColorRGBa.PINK,
        0.5 to ColorRGBa.BLUE,
        1.0 to ColorRGBa.PINK.toHSLUVa()) // <-- note this one is in hsluv

for (c in cs blend (width / 40)) {
    drawer.fill = c
    drawer.stroke = null
    drawer.rectangle(0.0, 0.0, 40.0,  height.toDouble())
    drawer.translate(40.0, 0.0)
}

HSLUVa and HPLUVa colorspaces

Two color spaces are added: ColorHSLUVa and ColorHPLUVa, they are an implementation of the colorspaces presented at hsluv.org

Demos

DemoColorPlane01

source code

DemoColorPlane01Kt

DemoColorPlane02

source code

DemoColorPlane02Kt

DemoColorRange01

source code

DemoColorRange01Kt

DemoColorRange02

source code

DemoColorRange02Kt

DemoColorRange03

source code

DemoColorRange03Kt

DemoColorRange04

source code

DemoColorRange04Kt

DemoHSLUV01

source code

DemoHSLUV01Kt

DemoHSLUV02

source code

DemoHSLUV02Kt

DemoHistogram01

source code

DemoHistogram01Kt

DemoHistogram02

source code

DemoHistogram02Kt

DemoHistogram03

source code

DemoHistogram03Kt

DemoXSLUV01

source code

DemoXSLUV01Kt