Colour class test

Colour version 1.1.0

constructor

empty

Colour().swatch() #000000

shade of grey

Colour(0.000000).swatch() #000000
Colour(0.100000).swatch() #1a1a1a
Colour(0.200000).swatch() #333333
Colour(0.300000).swatch() #4c4c4c
Colour(0.400000).swatch() #666666
Colour(0.500000).swatch() #808080
Colour(0.600000).swatch() #999999
Colour(0.700000).swatch() #b2b2b2
Colour(0.800000).swatch() #cccccc
Colour(0.900000).swatch() #e6e6e6
Colour(1.000000).swatch() #ffffff

RGB values

Colour((0.2, 0.8, 0.7)).swatch() #33ccb2
Colour((0.0, 0.1, 1.0)).swatch() #001aff
Colour((1.0, 0.2, 0.9)).swatch() #ff33e6

hex RGB string

Colour("12f").swatch() #1122ff
Colour("ffCF00").swatch() #ffcf00
Colour("#399").swatch() #339999
Colour("#012345").swatch() #012345

named CSS3 colour

Colour("goldenrod").swatch() #daa520
Colour("slateblue").swatch() #6a5acd
Colour("SPRINGGREEN").swatch() #00ff7f
Colour("darkorchid").swatch() #9932cc

existing Colour object

Colour(Colour("goldenrod")).swatch() #daa520
Colour(Colour("midnightblue")).swatch() #191970
Colour(Colour("c09")).swatch() #cc0099

rgb methods

rgb

Colour().rgb((0, 0.2, 1)).swatch() #0033ff
Colour().rgb((1, 0.8, 0.4221)).swatch() #ffcc6c
Colour((1, 1, 0.5)).rgb((1, None, 0)).swatch() #ffff00
Colour().rgb((255, 23, 0), max=255).swatch() #ff1700
Colour().rgb((30, 77, 100), max=100).swatch() #4cc4ff
Colour().rgb((4, 6.9, 3.5), min=3.5, max=7.0).swatch() #24f800
Colour("goldenrod").rgb() (0.8549019607843137, 0.6470588235294118, 0.12549019607843137)
Colour("goldenrod").rgb(min=10, max=30) (27, 23, 13)
Colour("goldenrod").rgb(min=10.0, max=30.0) (27.098039215686274, 22.941176470588236, 12.509803921568627)

rgb255

Colour().rgb255((0, 55, 199)).swatch() #0037c7
Colour().rgb255((255, 0, 0)).swatch() #ff0000
Colour("goldenrod").rgb255((None, 255, None)).swatch() #daff20
Colour("goldenrod").rgb255() (218, 165, 32)

rgb100

Colour().rgb100((0, 55, 88)).swatch() #008ce0
Colour().rgb100((100, 0, 0)).swatch() #ff0000
Colour("goldenrod").rgb100((None, 100, None)).swatch() #daff20
Colour("goldenrod").rgb100() (85, 65, 13)

hsv/hsl methods

hsv

Colour().hsv((0, 0.2, 1)).swatch() #ffcccc
Colour().hsv((300, 0.8, 0.4221)).swatch() #6c166c
Colour((1, 1, 0.5)).hsv((0, None, 0.5)).swatch() #804040
Colour().hsv((250, 88, 200), svmax=255).swatch() #8e83c8
Colour().hsv((180, 77, 40), svmax=100).swatch() #176666
Colour().hsv((0.9, 0.5, 0.5), hmin=0.0, hmax=1.0).swatch() #804140
Colour("blue").hsv((30, None, None)).swatch() #ff8000
Colour("blue").hsv((30, None, None), perceptual=True).swatch() #830400
Colour("goldenrod").hsv() (42.903225806451616, 0.8532110091743119, 0.8549019607843137)
Colour("goldenrod").hsv(hmin=10, hmax=30, svmin=0, svmax=50) (12, 43, 43)
Colour("goldenrod").hsv(hmin=10.0, hmax=30.0, svmin=0.0, svmax=50.0) (12.383512544802867, 42.6605504587156, 42.745098039215684)

hsl

Colour().hsl((0, 0.2, 1)).swatch() #ffffff
Colour().hsl((300, 0.8, 0.4221)).swatch() #c216c2
Colour((1, 1, 0.5)).hsl((0, None, 0.5)).swatch() #ff0000
Colour().hsl((250, 88, 200), slmax=255).swatch() #bbb5db
Colour().hsl((180, 77, 40), slmax=100).swatch() #17b5b5
Colour().hsl((0.9, 0.5, 0.5), hmin=0.0, hmax=1.0).swatch() #bf4240
Colour("blue").hsl((30, None, None)).swatch() #ff8000
Colour("blue").hsl((30, None, None), perceptual=True).swatch() #830400
Colour("goldenrod").hsl() (42.903225806451616, 0.744, 0.49019607843137253)
Colour("goldenrod").hsl(hmin=10, hmax=30, slmin=0, slmax=50) (12, 37, 25)
Colour("goldenrod").hsl(hmin=10.0, hmax=30.0, slmin=0.0, slmax=50.0) (12.383512544802867, 37.2, 24.509803921568626)

hs[vl]255

Colour().hsv255((90, 45, 255)).swatch() #e8ffd2
Colour().hsl255((90, 45, 255)).swatch() #ffffff
Colour().hsv255((270, 255, 180)).swatch() #5a00b4
Colour().hsl255((270, 255, 180)).swatch() #b469ff
Colour("goldenrod").hsv255() (43, 218, 218)
Colour("goldenrod").hsl255() (43, 190, 125)

hs[vl]100

Colour().hsv100((90, 45, 100)).swatch() #c6ff8c
Colour().hsl100((90, 45, 100)).swatch() #ffffff
Colour().hsv100((270, 100, 44)).swatch() #380070
Colour().hsl100((270, 100, 44)).swatch() #7000e0
Colour("goldenrod").hsv100() (43, 85, 85)
Colour("goldenrod").hsl100() (43, 74, 49)

yiq

Colour().yiq((0.5, -0.2, 1)).swatch() #ee00ff
Colour().yiq((1, 0.8, -0.4221)).swatch() #ffff00
Colour((1, 1, 0.5)).yiq((0, None, 0.5)).swatch() #7600ac
Colour().yiq((0.75, -185, -20), iqmin=-255, iqmax=255).swatch() #ff6bff
Colour().yiq((0.4, -100, -88), iqmin=-100, iqmax=100).swatch() #705c80
Colour().yiq((45, -1, 0.5), ymin=40, ymax=60).swatch() #0035ff
Colour("goldenrod").yiq() (0.6520392156862744, 0.2922866666666667, -0.1185109803921568)

hex

Colour().hex("abc").swatch() #aabbcc
Colour().hex("#DEf").swatch() #ddeeff
Colour().hex("#007bcc").swatch() #007bcc
Colour().hex("9000f0").swatch() #9000f0
Colour("goldenrod").hex() #daa520
Colour("goldenrod").hex(hash=False) daa520
Colour("goldenrod").hex(allowshort=True) #daa520
Colour("goldenrod").hex(forceshort=True) #da2
Colour("red").hex() #ff0000
Colour("red").hex(allowshort=True) #f00

css3

Colour().css3("goldenrod").swatch() #daa520
Colour().css3("GOLDENrod").swatch() #daa520
Colour().css3("wheat").swatch() #f5deb3
Colour((0.8, 1, 0.1)).css3() None
Colour("daa520").css3() goldenrod

grey

Colour().grey(0.000000).swatch() #000000
Colour().grey(0.142857).swatch() #242424
Colour().grey(0.285714).swatch() #494949
Colour().grey(0.428571).swatch() #6d6d6d
Colour().grey(0.571429).swatch() #929292
Colour().grey(0.714286).swatch() #b6b6b6
Colour().grey(0.857143).swatch() #dbdbdb
Colour().grey(1.000000).swatch() #ffffff
Colour("goldenrod").grey() False
Colour("grey").grey() 0.5019607843137255

hash

Colour().hash("tremby").swatch() #a96590
Colour().hash("yappy").swatch() #3bc5d6
Colour().hash("mon").swatch() #a18254
Colour().hash("bill").swatch() #ff78ce
Colour().hash("tremby", minh=-15, maxh=15).swatch() #a66f62
Colour().hash("yappy", minh=-15, maxh=15).swatch() #ff706e
Colour().hash("mon", minh=-15, maxh=15).swatch() #bb6e7d
Colour().hash("bill", minh=-15, maxh=15).swatch() #ff8e6f
Colour().hash("tremby", mins=0, maxs=0.3).swatch() #887882
Colour().hash("yappy", mins=0, maxs=0.3).swatch() #80a9ae
Colour().hash("mon", mins=0, maxs=0.3).swatch() #8d857a
Colour().hash("bill", mins=0, maxs=0.3).swatch() #cca0b9
Colour().hash("tremby", miny=0, maxy=0.2).swatch() #21141c
Colour().hash("yappy", miny=0, maxy=0.2).swatch() #0f3337
Colour().hash("mon", miny=0, maxy=0.2).swatch() #231c12
Colour().hash("bill", miny=0, maxy=0.2).swatch() #4e223a
Colour().hash(1).swatch() #64417b
Colour().hash(9.22).swatch() #946a45
Colour().hash("blah").swatch() #45a881
Colour().hash(None).swatch() #79b799
Colour().hash(Colour("goldenrod")).swatch() #6a4e43
Colour().hash(Colour("red")).swatch() #a263b3
Colour().hash([2, 3, 3]).swatch() #35c9b4

hue methods

hue

Colour("goldenrod").hue(340).swatch() #da205e
Colour("goldenrod").hue(340, perceptual=True).swatch() #ff68a6
Colour("goldenrod").hue(30).swatch() #da7d20
Colour("goldenrod").hue(-30).swatch() #da207d
Colour("goldenrod").hue() 42.903225806451616
Colour("slateblue").hue() 248.3478260869565

shifthue

Colour("goldenrod").shifthue(340).swatch() #da6720
Colour("goldenrod").shifthue(340, perceptual=True).swatch() #ff8c45
Colour("goldenrod").shifthue(30).swatch() #b2da20
Colour("goldenrod").shifthue(-30).swatch() #da4820

saturation methods

saturation_hs[vl]

Colour("goldenrod").saturation_hsv(0.000000).swatch() #dadada
Colour("goldenrod").saturation_hsv(0.142857).swatch() #dad1bb
Colour("goldenrod").saturation_hsv(0.285714).swatch() #dac89c
Colour("goldenrod").saturation_hsv(0.428571).swatch() #dabf7d
Colour("goldenrod").saturation_hsv(0.571429).swatch() #dab75d
Colour("goldenrod").saturation_hsv(0.714286).swatch() #daae3e
Colour("goldenrod").saturation_hsv(0.857143).swatch() #daa51f
Colour("goldenrod").saturation_hsv(1.000000).swatch() #da9c00
Colour("goldenrod").saturation_hsv(0.000000, perceptual=True).swatch() #a6a6a6
Colour("goldenrod").saturation_hsv(0.142857, perceptual=True).swatch() #afa690
Colour("goldenrod").saturation_hsv(0.285714, perceptual=True).swatch() #b8a679
Colour("goldenrod").saturation_hsv(0.428571, perceptual=True).swatch() #c0a663
Colour("goldenrod").saturation_hsv(0.571429, perceptual=True).swatch() #c9a54c
Colour("goldenrod").saturation_hsv(0.714286, perceptual=True).swatch() #d2a536
Colour("goldenrod").saturation_hsv(0.857143, perceptual=True).swatch() #daa51f
Colour("goldenrod").saturation_hsv(1.000000, perceptual=True).swatch() #e3a509
Colour("goldenrod").saturation_hsl(0.000000).swatch() #7d7d7d
Colour("goldenrod").saturation_hsl(0.142857).swatch() #8f856b
Colour("goldenrod").saturation_hsl(0.285714).swatch() #a18c59
Colour("goldenrod").saturation_hsl(0.428571).swatch() #b39447
Colour("goldenrod").saturation_hsl(0.571429).swatch() #c49c36
Colour("goldenrod").saturation_hsl(0.714286).swatch() #d6a324
Colour("goldenrod").saturation_hsl(0.857143).swatch() #e8ab12
Colour("goldenrod").saturation_hsl(1.000000).swatch() #fab300
Colour("goldenrod").saturation_hsl(0.000000, perceptual=True).swatch() #a6a6a6
Colour("goldenrod").saturation_hsl(0.142857, perceptual=True).swatch() #b0a68c
Colour("goldenrod").saturation_hsl(0.285714, perceptual=True).swatch() #baa673
Colour("goldenrod").saturation_hsl(0.428571, perceptual=True).swatch() #c4a659
Colour("goldenrod").saturation_hsl(0.571429, perceptual=True).swatch() #cea53f
Colour("goldenrod").saturation_hsl(0.714286, perceptual=True).swatch() #d8a525
Colour("goldenrod").saturation_hsl(0.857143, perceptual=True).swatch() #e2a50c
Colour("goldenrod").saturation_hsl(1.000000, perceptual=True).swatch() #eca500
Colour("goldenrod").saturation_hsv() 0.8532110091743119
Colour("goldenrod").saturation_hsl() 0.744

shiftsaturation_hs[vl]

Colour("goldenrod").shiftsaturation_hsv(-1.000000).swatch() #dadada
Colour("goldenrod").shiftsaturation_hsv(-0.714286).swatch() #dacba5
Colour("goldenrod").shiftsaturation_hsv(-0.428571).swatch() #dabc70
Colour("goldenrod").shiftsaturation_hsv(-0.142857).swatch() #daad3b
Colour("goldenrod").shiftsaturation_hsv(0.142857).swatch() #daa41b
Colour("goldenrod").shiftsaturation_hsv(0.428571).swatch() #daa112
Colour("goldenrod").shiftsaturation_hsv(0.714286).swatch() #da9e09
Colour("goldenrod").shiftsaturation_hsv(1.000000).swatch() #da9c00
Colour("goldenrod").shiftsaturation_hsv(-1.000000, perceptual=True).swatch() #a6a6a6
Colour("goldenrod").shiftsaturation_hsv(-0.714286, perceptual=True).swatch() #b5a680
Colour("goldenrod").shiftsaturation_hsv(-0.428571, perceptual=True).swatch() #c4a65a
Colour("goldenrod").shiftsaturation_hsv(-0.142857, perceptual=True).swatch() #d3a533
Colour("goldenrod").shiftsaturation_hsv(0.142857, perceptual=True).swatch() #dba51d
Colour("goldenrod").shiftsaturation_hsv(0.428571, perceptual=True).swatch() #dea516
Colour("goldenrod").shiftsaturation_hsv(0.714286, perceptual=True).swatch() #e0a50f
Colour("goldenrod").shiftsaturation_hsv(1.000000, perceptual=True).swatch() #e3a509
Colour("goldenrod").shiftsaturation_hsl(-1.000000).swatch() #7d7d7d
Colour("goldenrod").shiftsaturation_hsl(-0.714286).swatch() #988862
Colour("goldenrod").shiftsaturation_hsl(-0.428571).swatch() #b29448
Colour("goldenrod").shiftsaturation_hsl(-0.142857).swatch() #cd9f2d
Colour("goldenrod").shiftsaturation_hsl(0.142857).swatch() #dfa71b
Colour("goldenrod").shiftsaturation_hsl(0.428571).swatch() #e8ab12
Colour("goldenrod").shiftsaturation_hsl(0.714286).swatch() #f1af09
Colour("goldenrod").shiftsaturation_hsl(1.000000).swatch() #fab300
Colour("goldenrod").shiftsaturation_hsl(-1.000000, perceptual=True).swatch() #a6a6a6
Colour("goldenrod").shiftsaturation_hsl(-0.714286, perceptual=True).swatch() #b5a680
Colour("goldenrod").shiftsaturation_hsl(-0.428571, perceptual=True).swatch() #c4a65a
Colour("goldenrod").shiftsaturation_hsl(-0.142857, perceptual=True).swatch() #d3a533
Colour("goldenrod").shiftsaturation_hsl(0.142857, perceptual=True).swatch() #dda519
Colour("goldenrod").shiftsaturation_hsl(0.428571, perceptual=True).swatch() #e2a50c
Colour("goldenrod").shiftsaturation_hsl(0.714286, perceptual=True).swatch() #e7a500
Colour("goldenrod").shiftsaturation_hsl(1.000000, perceptual=True).swatch() #eca500

lightness methods

intensity

Colour("darkblue").intensity(0.000000).swatch() #000000
Colour("darkblue").intensity(0.142857).swatch() #00006d
Colour("darkblue").intensity(0.285714).swatch() #20209a
Colour("darkblue").intensity(0.428571).swatch() #4d4dae
Colour("darkblue").intensity(0.571429).swatch() #7979c2
Colour("darkblue").intensity(0.714286).swatch() #a6a6d6
Colour("darkblue").intensity(0.857143).swatch() #d2d2eb
Colour("darkblue").intensity(1.000000).swatch() #ffffff
Colour("goldenrod").intensity() 0.5424836601307189
Colour("darkblue").intensity() 0.18169934640522875

shiftintensity

Colour("darkblue").shiftintensity(-1.000000).swatch() #000000
Colour("darkblue").shiftintensity(-0.714286).swatch() #000028
Colour("darkblue").shiftintensity(-0.428571).swatch() #00004f
Colour("darkblue").shiftintensity(-0.142857).swatch() #000077
Colour("darkblue").shiftintensity(0.142857).swatch() #24249c
Colour("darkblue").shiftintensity(0.428571).swatch() #6d6dbd
Colour("darkblue").shiftintensity(0.714286).swatch() #b6b6de
Colour("darkblue").shiftintensity(1.000000).swatch() #ffffff

value

Colour("darkblue").value(0.000000).swatch() #000000
Colour("darkblue").value(0.142857).swatch() #000024
Colour("darkblue").value(0.285714).swatch() #000049
Colour("darkblue").value(0.428571).swatch() #00006d
Colour("darkblue").value(0.571429).swatch() #000092
Colour("darkblue").value(0.714286).swatch() #0000b6
Colour("darkblue").value(0.857143).swatch() #0000db
Colour("darkblue").value(1.000000).swatch() #0000ff
Colour("goldenrod").value() 0.8549019607843137
Colour("darkblue").value() 0.5450980392156862

shiftvalue

Colour("darkblue").shiftvalue(-1.000000).swatch() #000000
Colour("darkblue").shiftvalue(-0.714286).swatch() #000028
Colour("darkblue").shiftvalue(-0.428571).swatch() #00004f
Colour("darkblue").shiftvalue(-0.142857).swatch() #000077
Colour("darkblue").shiftvalue(0.142857).swatch() #00009c
Colour("darkblue").shiftvalue(0.428571).swatch() #0000bd
Colour("darkblue").shiftvalue(0.714286).swatch() #0000de
Colour("darkblue").shiftvalue(1.000000).swatch() #0000ff

lightness

Colour("darkblue").lightness(0.000000).swatch() #000000
Colour("darkblue").lightness(0.142857).swatch() #000049
Colour("darkblue").lightness(0.285714).swatch() #000092
Colour("darkblue").lightness(0.428571).swatch() #0000db
Colour("darkblue").lightness(0.571429).swatch() #2424ff
Colour("darkblue").lightness(0.714286).swatch() #6d6dff
Colour("darkblue").lightness(0.857143).swatch() #b6b6ff
Colour("darkblue").lightness(1.000000).swatch() #ffffff
Colour("goldenrod").lightness() 0.49019607843137253
Colour("darkblue").lightness() 0.2725490196078431

shiftlightness

Colour("darkblue").shiftlightness(-1.000000).swatch() #000000
Colour("darkblue").shiftlightness(-0.714286).swatch() #000028
Colour("darkblue").shiftlightness(-0.428571).swatch() #00004f
Colour("darkblue").shiftlightness(-0.142857).swatch() #000077
Colour("darkblue").shiftlightness(0.142857).swatch() #0000c0
Colour("darkblue").shiftlightness(0.428571).swatch() #2b2bff
Colour("darkblue").shiftlightness(0.714286).swatch() #9595ff
Colour("darkblue").shiftlightness(1.000000).swatch() #ffffff

luma

Colour("darkblue").luma(0.000000).swatch() #00007c
Colour("darkblue").luma(0.142857).swatch() #1515a0
Colour("darkblue").luma(0.285714).swatch() #3a3ac5
Colour("darkblue").luma(0.428571).swatch() #5e5ee9
Colour("darkblue").luma(0.571429).swatch() #8282ff
Colour("darkblue").luma(0.714286).swatch() #a7a7ff
Colour("darkblue").luma(0.857143).swatch() #cbcbff
Colour("darkblue").luma(1.000000).swatch() #f0f0ff
Colour("goldenrod").luma() 0.6520392156862744
Colour("darkblue").luma() 0.059960784313725486

shiftluma

Colour("darkblue").shiftluma(-1.000000).swatch() #00007c
Colour("darkblue").shiftluma(-0.714286).swatch() #000080
Colour("darkblue").shiftluma(-0.428571).swatch() #000084
Colour("darkblue").shiftluma(-0.142857).swatch() #000089
Colour("darkblue").shiftluma(0.142857).swatch() #2222ad
Colour("darkblue").shiftluma(0.428571).swatch() #6767f2
Colour("darkblue").shiftluma(0.714286).swatch() #ababff
Colour("darkblue").shiftluma(1.000000).swatch() #f0f0ff

mix

Colour("goldenrod").mix(Colour("darkblue"), 0.000000).swatch() #daa520
Colour("goldenrod").mix(Colour("darkblue"), 0.142857).swatch() #bb8d2f
Colour("goldenrod").mix(Colour("darkblue"), 0.285714).swatch() #9c763f
Colour("goldenrod").mix(Colour("darkblue"), 0.428571).swatch() #7d5e4e
Colour("goldenrod").mix(Colour("darkblue"), 0.571429).swatch() #5d475d
Colour("goldenrod").mix(Colour("darkblue"), 0.714286).swatch() #3e2f6c
Colour("goldenrod").mix(Colour("darkblue"), 0.857143).swatch() #1f187c
Colour("goldenrod").mix(Colour("darkblue"), 1.000000).swatch() #00008b

swatch

Colour("goldenrod").swatch() #daa520
Colour("goldenrod").swatch(showhex=False)        
Colour("goldenrod").swatch(cssclass="reallybig") #daa520

conversion functions

colour.rgbtohsv((0.2, 0.8, 0)) (105.0, 1.0, 0.8)
colour.rgbtohsl((0.2, 0.8, 0)) (105.0, 1.0, 0.4)
colour.rgbtoyiq((0.2, 0.8, 0)) (0.532, -0.10203999999999999, -0.37748000000000004)
colour.hsvtorgb((88, 0.8, 0.4)) (0.2506666666666667, 0.4, 0.07999999999999999)
colour.hsltorgb((88, 0.8, 0.4)) (0.42133333333333345, 0.7200000000000001, 0.07999999999999996)
colour.yiqtorgb((0.7, -0.8, 0.4)) (0.19191685912240186, 0.6655536853642305, 1.0)
colour.hextorgb("#342") (0.2, 0.26666666666666666, 0.13333333333333333)
colour.rgbtohex((0.2, 0.8, 0)) #33cc00

cubes

RGB


















































HSV





















































































HSL





















































































YIQ