The Color Module

The Color class is another fundamental class in the Paynter library. This module will mange the creation, modification, and storing of colors and palettes.

The color class is mainly used internally by the Paynter class, but the user will still have to create the palette and sets the active colors manually through Paynter.setColor(color).

The Color Class

class paynter.color.Color(r, g, b, a)

The Color class has 4 0-1 floats, one for each RGBA channel.

A Color class is created from palette functions or directly with their constructor.

from paynter import *

#Get a list of colors
palette = getColors_Triad(spread = 20)

#You can create with 0-1 floats..
otherColor = Color(1, 0.5, 0, 1)

#.. or with 0-255 ints
sameColor = Color(255, 128, 0, 255)
Color.get_0_255()

Gets the RGBA 0-255 rappresentation of this color.

Return type:A list of 4 ints.
Color.get_0_1()

Gets the RGBA 0-1 rappresentation of this color.

Return type:A list of 4 floats.
Color.get_HSV()

Gets the HSV 0-1 rappresentation of this color. This does ignore the alpha value.

Return type:A list of 3 floats.
Color.set_HSV(h, s, v)

Overwrite the current color with this set of HSV values. This keeps the current alpha value.

Parameters:
  • h – A 0-1 float with the Hue.
  • s – A 0-1 float with the Saturation.
  • v – A 0-1 float with the Value.
Return type:

The new Color object.

Color.set_alpha(newAlpha)

Overwrite the current alpha value.

Parameters:newAlpha – A 0-1 float with the desired alpha.
Return type:The Color object.
Color.get_alpha()

Gets the current alpha value.

Return type:A 0-1 float.
Color.tweak_Hue(ammount)

Change the current hue value by a certain ammount.

Parameters:ammount – A 0-1 float with the ammount to sum to the current hue.
Return type:The Color object.
Color.tweak_Sat(ammount)

Change the current saturation value by a certain ammount.

Parameters:ammount – A 0-1 float with the ammount to sum to the current saturation.
Return type:The Color object.
Color.tweak_Val(ammount)

Change the current value value by a certain ammount.

Parameters:ammount – A 0-1 float with the ammount to sum to the current value.
Return type:The Color object.
Color.copy()

Creates a copy of this Color.

Return type:The new Color object.