ColorPicker¶
-
class
pygamelib.gfx.ui.ColorPicker(orientation: int = None, config: pygamelib.gfx.ui.UiConfig = None)¶ Bases:
objectThe ColorPicker widget is a simple object to select the red, green and blue components of a color.
It provides the API to set/get each color channel independently as well as the mechanism to select and draw a selection box around one specific channel to give the user a visual cue about what he is modifying.
-
__init__(orientation: int = None, config: pygamelib.gfx.ui.UiConfig = None) → None¶ The constructor is really simple and takes only 2 arguments.
Parameters: - orientation (int) – One of the 2 orientation constants
pygamelib.constants.ORIENTATION_HORIZONTALorpygamelib.constants.ORIENTATION_VERTICAL - config (
UiConfig) – The configuration object.
The default orientation is horizontal.
Warning
The orientation parameter is ignored for the moment.
Example:
color_picker = ColorPicker(constants.ORIENTATION_HORIZONTAL, conf) screen.place(color_picker, 10, 10) screen.update()
- orientation (int) – One of the 2 orientation constants
Methods
__init__(orientation, config)The constructor is really simple and takes only 2 arguments. render_to_buffer(buffer, row, column, …)Render the object from the display buffer to the frame buffer. Attributes
blueGet / set the blue component of the color, the value needs to be an int between 0 and 255. colorGet / set the edited color. greenGet / set the green component of the color, the value needs to be an int between 0 and 255. redGet / set the red component of the color, the value needs to be an int between 0 and 255. selectionGet / set the selection, it needs to be an int between 0 and 2 included. -
blue¶ Get / set the blue component of the color, the value needs to be an int between 0 and 255.
-
color¶ Get / set the edited color.
The setter automatically forward the individual red, green and blue values to to the proper properties of that widget.
Parameters: value ( Color) – The color object.Example:
current_color = color_picker.color current_color.r += 10 color_picker.color = current_color
-
green¶ Get / set the green component of the color, the value needs to be an int between 0 and 255.
-
red¶ Get / set the red component of the color, the value needs to be an int between 0 and 255.
-
render_to_buffer(buffer, row: int, column: int, buffer_height: int, buffer_width: int) → None¶ Render the object from the display buffer to the frame buffer.
This method is automatically called by
pygamelib.engine.Screen.render().Parameters: - buffer (numpy.array) – A screen buffer to render the item into.
- row (int) – The row to render in.
- column (int) – The column to render in.
- height (int) – The total height of the display buffer.
- width (int) – The total width of the display buffer.
-