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_points_for_thick_line(start_x: float, start_y: float, end_x: float, end_y: float, line_width: float)[source]#

Function used internally for Arcade. OpenGL draws triangles only, so a thick line must be two triangles that make up a rectangle. This calculates and returns those points.

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

arcade.uint24_to_three_byte_color#

arcade.uint24_to_three_byte_color(color: int) Union[Tuple[int, int, int], List[int]][source]#

Given an int between 0 and 16777215, return a RGB color tuple.

Example:

>>> arcade.uint24_to_three_byte_color(16777215)
(255, 255, 255)
Parameters:

color (int) – 3 byte int

arcade.uint32_to_four_byte_color#

arcade.uint32_to_four_byte_color(color: int) Union[Tuple[int, int, int, int], List[int]][source]#

Given an int between 0 and 4294967295, return a RGBA color tuple.

Example:

>>> arcade.uint32_to_four_byte_color(4294967295)
(255, 255, 255, 255)
Parameters:

color (int) – 4 byte int