BPY plus – color module

A BPY plus module to simplify work with colors.

Usage example

Color class

equal(color_1, color_2, , rel_tol=1e-09, abs_tol=0.0001)

Compares two colors, return True if they are equal and False if not.

Parameters:

color_1: color to compare

color_2: color to compare

rel_tol: relative tolerance

abs_tol: absolute tolerance

Returns:

Compare result – True or False


random(alpha=False)

Returns random color

Parameters:

alpha: if True – return random alpha too, else return alpha = 1.0

Returns:

A tuple with random color values.


linear_to_srgb(color_value)

Convert color value from Linear color space (Blender native) to sRGB color space

Parameters:

color_value: color value in Linear color space in 0.0 … 1.0 range

Returns:

color value in sRGB color space in 0 – 255 range

 


srgb_to_linear(color_value)

Convert color value from sRGB color space to Linear color space (Blender native)

Parameters:

color_value: color_value: color value in sRGB color space in 0 – 255 range

Returns:

color value in Linear color space in 0.0 – 1.0 range

 


rgba_to_rgb565(rgba)

Convert color from RGBA format to RGB565 format

Parameters:

rgba: color in RGBA format, list/tuple of 4 color components (R, G, B, A) in range (0-255, 0-255, 0-255, 0-255)

Returns:

color in RGB565 format, 2-bytes int, in 0-65535 range

 


 

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comment
Newest
Oldest Most Voted
Inline Feedbacks
View all comments