This repository was archived by the owner on Sep 26, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Color
Hamolicious edited this page Jun 11, 2021
·
2 revisions
A 3 dimensional vector data structure with additional functions for color manipulation.
I highly recommend reading the instantiation page before anything else to get an understanding of what *args will take
| Property | Description |
|---|---|
r |
the 0th element of the vector |
g |
the 1st element of the vector |
b |
the 2nd element of the vector |
hex |
returns the hex representation of the RGB colour |
| Method | Description |
|---|---|
__init__(*args) |
Have a look at the instantiation page |
random() |
Static method, returns a color where r, g, and b are between 0 and 255 |
from_hex(hex) |
Static method, creates a color from a hex code (eg. "#bada55") |
from_hsv(hex) |
Static method, creates a color from hsv data where 0 <= h < 360, 0 <= s < 100, 0 <= v < 100
|
zero() |
Static method, returns a zero color, same as instantiating an empty color Color()
|
as_unit() |
gets the color as a tuple in the form 0 <= elem < 1
|
as_hex() |
gets the color as a string |
as_hsv() |
gets the color as a tuple in the form 0 <= h < 360, 0 <= s < 100, 0 <= v < 100
|
get() |
gets the color as a tuple in the form 0 <= elem < 255
|
set(*args) |
same as __init__(*args)
|
copy() |
returns a copy of the color |
clear() |
sets all elements to 0 |
add(*args) |
adds each element with the passed in elements |
sub(*args) |
subtracts each element with the passed in elements |
mult(*args) |
multiplies each element with the passed in elements |
div(*args) |
divides each element with the passed in elements |
linear_interpolate(*args, t=0.5) |
linearly interpolates the color to the passed in values |