No description
Find a file
Adam Chesak b466a50424 Merge pull request #1 from WetDesertRock/patch-1
Update to for min/max, as well silence silly warnings
2017-06-14 20:09:39 -05:00
colorsys.nim Update to for min/max, as well silence silly warnings 2017-06-13 21:05:57 -06:00
colorsys.nimble 0.2 update 2016-05-31 14:26:39 -05:00
LICENSE.md 0.2 update 2016-05-31 14:26:39 -05:00
README.md 0.2 update 2016-05-31 14:26:39 -05:00

About

nim-colorsys is a Nim module for converting between the RGB, YIQ, HLS, and HSV color systems. It is a port of the colorsys module in the Python standard library.

All coordinates used are floats, between 0 and 1 (the exception being I and Q in the YIQ color space, which can be positive or negative).

Example:

# Gold color
var rgb : seq[float] = @[1.00, 0.84, 0.00]

# Convert to other color systems.
var yiq : seq[float] = rgbToYiq(rgb)
var hls : seq[float] = rgbToHls(rgb)
var hsv : seq[float] = rgbToHsv(rgb)

# Output the color in each system.
echo("RGB: " & $rgb) # outputs "RGB: @[1.0, 0.84, 0.0]"
echo("YIQ: " & $yiq) # outputs "YIQ: @[0.7955999999999999, 0.3648, -0.2268]"
echo("HLS: " & $hls) # outputs "HLS: @[0.14, 0.5, 1.0]"
echo("HSV: " & $hsv) # outputs "HSV: @[0.14, 1.0, 1.0]"

Example based on Python colorsys example at http://effbot.org/librarybook/colorsys.htm.

License

nim-colorsys is released under the MIT open source license.