Drawing - Utility#
arcade.color_from_hex_string#
- arcade.color_from_hex_string(code: str) Union[Tuple[int, int, int, int], List[int]] [source]#
Make a color from a hex code (3, 4, 6 or 8 characters of hex, normally with a hashtag). Supports most formats used in CSS. Returns an RGBA color.
Examples:
>>> arcade.color_from_hex_string("#ff00ff") (255, 0, 255, 255) >>> arcade.color_from_hex_string("#ff00ff00") (255, 0, 255, 0) >>> arcade.color_from_hex_string("#fff") (255, 255, 255, 255)
arcade.float_to_byte_color#
- arcade.float_to_byte_color(color: Union[Tuple[float, float, float, float], Tuple[float, float, float]]) Union[Tuple[int, int, int], List[int], Tuple[int, int, int, int]] [source]#
Converts a float colors to a byte color. This works for 3 of 4-component colors.
Example:
>>> arcade.float_to_byte_color((1.0, 0.5, 0.25, 1.0)) (255, 127, 63, 255) >>> arcade.float_to_byte_color((1.0, 0.5, 0.25)) (255, 127, 63)
arcade.get_four_byte_color#
- arcade.get_four_byte_color(color: Union[Tuple[int, int, int], List[int], Tuple[int, int, int, int]]) Union[Tuple[int, int, int, int], List[int]] [source]#
Converts a color to RGBA. If the color is already RGBA the original color value will be returned. If the alpha channel is not present a 255 value will be added.
This function is useful when a mix of RGB and RGBA values are used and you need to enforce RGBA.
Examples:
>>> arcade.get_four_byte_color((255, 255, 255)) (255, 255, 255, 255)
- Parameters:
color (Color) – Three or four byte tuple
- Returns:
return: Four byte RGBA tuple
arcade.get_four_float_color#
- arcade.get_four_float_color(color: Union[Tuple[int, int, int], List[int], Tuple[int, int, int, int]]) Tuple[float, float, float, float] [source]#
Converts an RGB or RGBA byte color to a floating point RGBA color. Basically we divide each component by 255. Float based colors are often used with OpenGL.
Examples:
>>> arcade.get_four_float_color((255, 127, 0)) (1.0, 0.4980392156862745, 0.0, 1.0) >>> arcade.get_four_float_color((255, 255, 255, 127)) (1.0, 1.0, 1.0, 0.4980392156862745)
- Parameters:
color (Color) – Three or four byte tuple
- Returns:
Four floats as a RGBA tuple
arcade.get_points_for_thick_line#
arcade.get_three_float_color#
- arcade.get_three_float_color(color: Union[Tuple[int, int, int], List[int], Tuple[int, int, int, int]]) Tuple[float, float, float] [source]#
Converts an RGB or RGBA byte color to a floating point RGB color. Basically we divide each component by 255. Float based colors are often used with OpenGL.
Examples:
>>> arcade.get_three_float_color(arcade.color.RED) (1.0, 0.0, 0.0) >>> arcade.get_three_float_color((255, 255, 255, 255)) (1.0, 1.0, 1.0)
- Parameters:
color (Color) – Three or four byte tuple
- Returns:
Three floats as a RGB tuple
arcade.make_transparent_color#
- arcade.make_transparent_color(color: Union[Tuple[int, int, int], List[int], Tuple[int, int, int, int]], transparency: float)[source]#
Given a RGB color, along with an alpha, returns an RGBA color tuple:
(R, G, B, transparency)
.Example:
>>> arcade.make_transparent_color((255, 255, 255), 127) (255, 255, 255, 127)
- Parameters:
color (Color) – Three or four byte RGBA color
transparency (float) – Transparency