pygame_gui.core.drawable_shapes package

Submodules

pygame_gui.core.drawable_shapes.drawable_shape module

class pygame_gui.core.drawable_shapes.drawable_shape.DrawableShape(containing_rect: Rect, theming_parameters: Dict, states: List[str], manager: IUIManagerInterface, *, allow_text_outside_width_border=True, allow_text_outside_height_border=True, text_x_scroll_enabled=False, editable_text=False)

Bases: object

Base class for a graphical 'shape' that we can use for many different UI elements. The intent is to make it easy to switch between UI elements having normal rectangles, circles or rounded rectangles as their visual shape while having the same non-shape related functionality.

Parameters:
  • containing_rect -- The rectangle which this shape is entirely contained within (including shadows, borders etc)

  • theming_parameters -- A dictionary of user supplied data that alters the appearance of the shape.

  • states -- Names for the different states the shape can be in, each may have different sets of colours & images.

  • manager -- The UI manager for this UI.

align_all_text_rows()

Aligns the text drawing position correctly according to our theming options.

apply_active_text_changes()

Updates the shape surface with any changes to the text surface. Useful when we've made small edits to the text surface

build_text_layout()

Build a text box layout for this drawable shape if it has some text.

clean_up_temp_shapes()

This method is declared for derived classes to implement but has no default implementation.

collide_point(point: Vector2 | Tuple[int, int] | Tuple[float, float])

This method is declared for derived classes to implement but has no default implementation.

Parameters:

point -- A point to collide with this shape.

finalise_images_and_text(image_state_str: str, state_str: str, text_colour_state_str: str, text_shadow_colour_state_str: str, add_text: bool)

Rebuilds any text or image used by a specific state in the drawable shape. Effectively this means adding them on top of whatever is already in the state's surface. As such it should generally be called last in the process of building up a finished drawable shape state.

Parameters:
  • add_text --

  • image_state_str -- image ID of the state we are going to be adding images and text to.

  • state_str -- normal ID of the state we are going to be adding images and text to.

  • text_colour_state_str -- text ID of the state we are going to be adding images and text to.

  • text_shadow_colour_state_str -- text shadow ID of the state we are going to be adding images and text to.

finalise_text(state_str, text_colour_state_str: str = '', text_shadow_colour_state_str: str = '', only_text_changed: bool = False)

Finalise the text to a surface with some last-minute data that doesn't require the text be re-laid out.

Parameters:
  • only_text_changed --

  • state_str -- The name of the shape's state we are finalising.

  • text_colour_state_str -- The string identifying the text colour to use.

  • text_shadow_colour_state_str -- The string identifying the text shadow colour to use.

finalise_text_onto_active_state()

Lets us draw the active state with no text and then paste the finalised surface from the text layout on top. Handy if we are doing some text effects in the text layout we don't want to lose by recreating the text from scratch.

full_rebuild_on_size_change()

Triggered when we've changed the size of the shape and need to rebuild basically everything to account for it.

get_active_state_surface() Surface

Get the main surface from the active state.

Returns:

The surface asked for, or the best available substitute.

get_fresh_surface() Surface

Gets the surface of the active state and resets the state's 'has_fresh_surface' variable.

Returns:

The active state's main pygame.surface.Surface.

get_surface(state_name: str) Surface

Get the main surface from a specific state.

Parameters:

state_name -- The state we are trying to get the surface from.

Returns:

The surface asked for, or the best available substitute.

has_fresh_surface() bool

Lets UI elements find out when a state has finished building a fresh surface for times when we have to delay it for whatever reason.

Returns:

True if there is a freshly built surface waiting, False if the shape has not changed.

insert_text(text: str, layout_index: int, parser: HTMLParser | None = None)

Update the theming when we insert text, then pass down to the layout to do the actual inserting. :param text: the text to insert :param layout_index: where to insert it :param parser: an optional parser :return:

redraw_active_state_no_text()

Redraw the currently active state with no text.

redraw_all_states(force_full_redraw: bool = False)

Starts the redrawing process for all states of this shape that auto pre-generate. Redrawing is done one state at a time so will take a few loops of the game to complete if this shape has many states.

redraw_state(state_str: str, add_text: bool = True)

This method is declared for derived classes to implement but has no default implementation.

Parameters:
  • add_text --

  • state_str -- The ID/name of the state to redraw.

set_active_state(state_id: str)

Changes the currently active state for the drawable shape and, if setup in the theme, creates a transition blend from the previous state to the newly active one.

Parameters:

state_id -- the ID of the new state to make active.

set_dimensions(dimensions: Vector2 | Tuple[int, int] | Tuple[float, float])

This method is declared for derived classes to implement but has no default implementation.

Parameters:

dimensions -- The new dimensions for our shape.

set_position(point: Vector2 | Tuple[int, int] | Tuple[float, float])

This method is declared for derived classes to implement but has no default implementation.

Parameters:

point -- A point to set this shapes position to.

set_text(text: str)

Set the visible text that the drawable shape has on it. This call will build a text layout and then redraw the final shape with the new, laid out text on top.

Parameters:

text -- the new string of text to stick on the shape.

set_text_alpha(alpha: int)

Set the alpha of just the text and redraw the shape with the new text on top.

Parameters:

alpha -- the alpha to set.

toggle_text_cursor()

Toggle the edit text cursor/carat between visible and invisible. Usually this is run to make the cursor appear to flash so it catches user attention.

update(time_delta: float)

Updates the drawable shape to process rebuilds and update blends between states.

Parameters:

time_delta -- amount of time passed between now and the previous frame in seconds.

class pygame_gui.core.drawable_shapes.drawable_shape.DrawableShapeState(state_id: str)

Bases: object

Represents a single state of a drawable shape.

Parameters:

state_id -- The ID/name of this state.

get_surface() Surface

Gets the pygame.surface.Surface of this state. Will be a blend of this state and the previous one if we are in a transition.

Returns:

A pygame Surface for this state.

update(time_delta: float)

Updates any transitions this state is in

Parameters:

time_delta -- The time passed between frames, measured in seconds.

class pygame_gui.core.drawable_shapes.drawable_shape.DrawableStateTransition(states: Dict[str, DrawableShapeState], start_state_id: str, target_state_id: str, duration: float, *, progress: float = 0.0)

Bases: object

Starts & controls a transition between two states of a drawable shape.

Parameters:
  • states -- A dictionary of all the drawable states.

  • start_state_id -- The state to start from.

  • target_state_id -- The state to transition to.

  • duration -- The length of the transition

  • progress -- The initial progress along the transition.

produce_blended_result() Surface

Produces a blend between the images of our start state and our target state. The progression of the blend is dictated by the progress of time through the transition.

Returns:

The blended surface.

update(time_delta: float)

Updates the timer for this transition.

Parameters:

time_delta -- The time passed between frames, measured in seconds.

pygame_gui.core.drawable_shapes.ellipse_drawable_shape module

class pygame_gui.core.drawable_shapes.ellipse_drawable_shape.EllipseDrawableShape(containing_rect: Rect, theming_parameters: Dict[str, Any], states: List[str], manager: IUIManagerInterface, *, allow_text_outside_width_border=True, allow_text_outside_height_border=True, text_x_scroll_enabled=False, editable_text=False)

Bases: DrawableShape

A drawable ellipse shape for the UI, has theming options for a border, a shadow, colour gradients and text.

Parameters:
  • containing_rect -- The layout rectangle that surrounds and controls the size of this shape.

  • theming_parameters -- Various styling parameters that control the final look of the shape.

  • states -- The different UI states the shape can be in. Shapes have different surfaces for each state.

  • manager -- The UI manager.

static clear_and_create_shape_surface(surface: Surface, rect: Rect, overlap: int, aa_amount: int, clear: bool = True) Surface

Clear a space for a new shape surface on the main state surface for this state. The surface created will be plain white so that it can be easily multiplied with a colour surface.

Parameters:
  • surface -- The surface we are working on.

  • rect -- Used to size and position the new shape.

  • overlap -- The amount of overlap between this surface and the one below.

  • aa_amount -- The amount of Anti Aliasing to use for this shape.

  • clear -- Whether we should clear our surface.

Returns:

The new shape surface.

collide_point(point: Vector2 | Tuple[int, int] | Tuple[float, float]) bool

Checks collision between a point and this ellipse.

Parameters:

point -- The point to test against the shape.

Returns:

True if the point is inside the shape.

full_rebuild_on_size_change()

Completely redraw the shape from it's theming parameters and dimensions.

redraw_state(state_str: str, add_text: bool = True)

Redraws the shape's surface for a given UI state.

Parameters:
  • add_text -- Whether to add the text to the shape in this redraw.

  • state_str -- The ID string of the state to rebuild.

set_dimensions(dimensions: Vector2 | Tuple[int, int] | Tuple[float, float])

Expensive size change of the ellipse shape.

Parameters:

dimensions -- The new size to set the shape to.

set_position(point: Vector2 | Tuple[int, int] | Tuple[float, float])

Move the shape. Only really impacts the position of the 'click_area' hot spot.

Parameters:

point -- The new position to move it to.

pygame_gui.core.drawable_shapes.rect_drawable_shape module

class pygame_gui.core.drawable_shapes.rect_drawable_shape.RectDrawableShape(containing_rect: Rect, theming_parameters: Dict[str, Any], states: List[str], manager: IUIManagerInterface, *, allow_text_outside_width_border=True, allow_text_outside_height_border=True, text_x_scroll_enabled=False, editable_text=False)

Bases: DrawableShape

A rectangle shape for UI elements has theming options for a border, a shadow, colour gradients and text.

Parameters:
  • containing_rect -- The layout rectangle that surrounds and controls the size of this shape.

  • theming_parameters -- Various styling parameters that control the final look of the shape.

  • states -- The different UI states the shape can be in. Shapes have different surfaces for each state.

  • manager -- The UI manager.

collide_point(point: Vector2 | Tuple[int, int] | Tuple[float, float]) bool

Tests if a point is colliding with our Drawable shape's 'click area' hot spot.

Parameters:

point -- The point to test.

Returns:

True if we are colliding.

full_rebuild_on_size_change()

Completely rebuilds the rectangle shape from it's dimensions and parameters.

Everything needs rebuilding if we change the size of the containing rectangle.

redraw_state(state_str: str, add_text: bool = True)

Redraws the shape's surface for a given UI state.

Parameters:
  • add_text --

  • state_str -- The ID string of the state to rebuild.

set_dimensions(dimensions: Vector2 | Tuple[int, int] | Tuple[float, float])

Changes the size of the rectangle shape. Relatively expensive to do.

Parameters:

dimensions -- The new dimensions.

set_position(point: Vector2 | Tuple[int, int] | Tuple[float, float])

Move the shape. Only really impacts the position of the 'click_area' hot spot.

Parameters:

point -- The new position to move it to.

pygame_gui.core.drawable_shapes.rounded_rect_drawable_shape module

class pygame_gui.core.drawable_shapes.rounded_rect_drawable_shape.RoundedRectangleShape(containing_rect: Rect, theming_parameters: Dict[str, Any], states: List[str], manager: IUIManagerInterface, *, allow_text_outside_width_border=True, allow_text_outside_height_border=True, text_x_scroll_enabled=False, editable_text=False)

Bases: DrawableShape

A drawable rounded rectangle shape for the UI, has theming options for a border, a shadow, colour gradients and text.

Parameters:
  • containing_rect -- The layout rectangle that surrounds and controls the size of this shape.

  • theming_parameters -- Various styling parameters that control the final look of the shape.

  • states -- The different UI states the shape can be in. Shapes have different surfaces for each state.

  • manager -- The UI manager.

clean_up_temp_shapes()

Clean up some temporary surfaces we use repeatedly when rebuilding multiple states of the shape but have no need of afterward.

clear_and_create_shape_surface(surface: Surface, rect: Rect, overlap: int, corner_radii: List[int], aa_amount: int, clear: bool = True) Surface

Clear a space for a new shape surface on the main state surface for this state. The surface created will be plain white so that it can be easily multiplied with a colour surface.

Parameters:
  • surface -- The surface we are working on.

  • rect -- Used to size and position the new shape.

  • overlap -- The amount of overlap between this surface and the one below.

  • corner_radii -- The radii of the rounded corners.

  • aa_amount -- The amount of Anti Aliasing to use for this shape.

  • clear -- Whether we should clear our surface.

Returns:

The new shape surface.

collide_point(point: Vector2 | Tuple[int, int] | Tuple[float, float]) bool

Checks collision between a point and this rounded rectangle.

Parameters:

point -- The point to test collision with.

Returns:

True, if the point is inside the shape.

create_subtract_surface(subtract_size: Tuple[int, int], corner_radii: List[int], aa_amount: int)

Create a rounded rectangle shaped surface that can be used to subtract everything from a surface to leave a transparent hole in it.

static draw_colourless_rounded_rectangle(large_corner_radius: List[int], large_shape_surface: Surface, corner_offset: int = 0)

Draw a rounded rectangle shape in pure white, so it is ready to be multiplied by a colour or gradient.

Parameters:
  • large_corner_radius -- The radius of the corners.

  • large_shape_surface -- The surface to draw onto, the shape fills the surface.

  • corner_offset -- Offsets the corners, used to help avoid overlaps that look bad.

full_rebuild_on_size_change()

Completely rebuilds the rounded rectangle shape from its dimensions and parameters.

Everything needs rebuilding if we change the size of the containing rectangle.

redraw_state(state_str: str, add_text: bool = True)

Redraws the shape's surface for a given UI state.

Parameters:
  • add_text --

  • state_str -- The ID string of the state to rebuild.

set_dimensions(dimensions: Vector2 | Tuple[int, int] | Tuple[float, float])

Changes the size of the rounded rectangle shape. Relatively expensive to completely do so has support for 'temporary rapid resizing' while the dimensions are being changed frequently.

Parameters:

dimensions -- The new dimensions.

set_position(point: Vector2 | Tuple[int, int] | Tuple[float, float])

Move the shape. Only really impacts the position of the 'click_area' hot spot.

Parameters:

point -- The new position to move it to.

Module contents

class pygame_gui.core.drawable_shapes.DrawableShape(containing_rect: Rect, theming_parameters: Dict, states: List[str], manager: IUIManagerInterface, *, allow_text_outside_width_border=True, allow_text_outside_height_border=True, text_x_scroll_enabled=False, editable_text=False)

Bases: object

Base class for a graphical 'shape' that we can use for many different UI elements. The intent is to make it easy to switch between UI elements having normal rectangles, circles or rounded rectangles as their visual shape while having the same non-shape related functionality.

Parameters:
  • containing_rect -- The rectangle which this shape is entirely contained within (including shadows, borders etc)

  • theming_parameters -- A dictionary of user supplied data that alters the appearance of the shape.

  • states -- Names for the different states the shape can be in, each may have different sets of colours & images.

  • manager -- The UI manager for this UI.

align_all_text_rows()

Aligns the text drawing position correctly according to our theming options.

apply_active_text_changes()

Updates the shape surface with any changes to the text surface. Useful when we've made small edits to the text surface

build_text_layout()

Build a text box layout for this drawable shape if it has some text.

clean_up_temp_shapes()

This method is declared for derived classes to implement but has no default implementation.

collide_point(point: Vector2 | Tuple[int, int] | Tuple[float, float])

This method is declared for derived classes to implement but has no default implementation.

Parameters:

point -- A point to collide with this shape.

finalise_images_and_text(image_state_str: str, state_str: str, text_colour_state_str: str, text_shadow_colour_state_str: str, add_text: bool)

Rebuilds any text or image used by a specific state in the drawable shape. Effectively this means adding them on top of whatever is already in the state's surface. As such it should generally be called last in the process of building up a finished drawable shape state.

Parameters:
  • add_text --

  • image_state_str -- image ID of the state we are going to be adding images and text to.

  • state_str -- normal ID of the state we are going to be adding images and text to.

  • text_colour_state_str -- text ID of the state we are going to be adding images and text to.

  • text_shadow_colour_state_str -- text shadow ID of the state we are going to be adding images and text to.

finalise_text(state_str, text_colour_state_str: str = '', text_shadow_colour_state_str: str = '', only_text_changed: bool = False)

Finalise the text to a surface with some last-minute data that doesn't require the text be re-laid out.

Parameters:
  • only_text_changed --

  • state_str -- The name of the shape's state we are finalising.

  • text_colour_state_str -- The string identifying the text colour to use.

  • text_shadow_colour_state_str -- The string identifying the text shadow colour to use.

finalise_text_onto_active_state()

Lets us draw the active state with no text and then paste the finalised surface from the text layout on top. Handy if we are doing some text effects in the text layout we don't want to lose by recreating the text from scratch.

full_rebuild_on_size_change()

Triggered when we've changed the size of the shape and need to rebuild basically everything to account for it.

get_active_state_surface() Surface

Get the main surface from the active state.

Returns:

The surface asked for, or the best available substitute.

get_fresh_surface() Surface

Gets the surface of the active state and resets the state's 'has_fresh_surface' variable.

Returns:

The active state's main pygame.surface.Surface.

get_surface(state_name: str) Surface

Get the main surface from a specific state.

Parameters:

state_name -- The state we are trying to get the surface from.

Returns:

The surface asked for, or the best available substitute.

has_fresh_surface() bool

Lets UI elements find out when a state has finished building a fresh surface for times when we have to delay it for whatever reason.

Returns:

True if there is a freshly built surface waiting, False if the shape has not changed.

insert_text(text: str, layout_index: int, parser: HTMLParser | None = None)

Update the theming when we insert text, then pass down to the layout to do the actual inserting. :param text: the text to insert :param layout_index: where to insert it :param parser: an optional parser :return:

redraw_active_state_no_text()

Redraw the currently active state with no text.

redraw_all_states(force_full_redraw: bool = False)

Starts the redrawing process for all states of this shape that auto pre-generate. Redrawing is done one state at a time so will take a few loops of the game to complete if this shape has many states.

redraw_state(state_str: str, add_text: bool = True)

This method is declared for derived classes to implement but has no default implementation.

Parameters:
  • add_text --

  • state_str -- The ID/name of the state to redraw.

set_active_state(state_id: str)

Changes the currently active state for the drawable shape and, if setup in the theme, creates a transition blend from the previous state to the newly active one.

Parameters:

state_id -- the ID of the new state to make active.

set_dimensions(dimensions: Vector2 | Tuple[int, int] | Tuple[float, float])

This method is declared for derived classes to implement but has no default implementation.

Parameters:

dimensions -- The new dimensions for our shape.

set_position(point: Vector2 | Tuple[int, int] | Tuple[float, float])

This method is declared for derived classes to implement but has no default implementation.

Parameters:

point -- A point to set this shapes position to.

set_text(text: str)

Set the visible text that the drawable shape has on it. This call will build a text layout and then redraw the final shape with the new, laid out text on top.

Parameters:

text -- the new string of text to stick on the shape.

set_text_alpha(alpha: int)

Set the alpha of just the text and redraw the shape with the new text on top.

Parameters:

alpha -- the alpha to set.

toggle_text_cursor()

Toggle the edit text cursor/carat between visible and invisible. Usually this is run to make the cursor appear to flash so it catches user attention.

update(time_delta: float)

Updates the drawable shape to process rebuilds and update blends between states.

Parameters:

time_delta -- amount of time passed between now and the previous frame in seconds.

class pygame_gui.core.drawable_shapes.EllipseDrawableShape(containing_rect: Rect, theming_parameters: Dict[str, Any], states: List[str], manager: IUIManagerInterface, *, allow_text_outside_width_border=True, allow_text_outside_height_border=True, text_x_scroll_enabled=False, editable_text=False)

Bases: DrawableShape

A drawable ellipse shape for the UI, has theming options for a border, a shadow, colour gradients and text.

Parameters:
  • containing_rect -- The layout rectangle that surrounds and controls the size of this shape.

  • theming_parameters -- Various styling parameters that control the final look of the shape.

  • states -- The different UI states the shape can be in. Shapes have different surfaces for each state.

  • manager -- The UI manager.

static clear_and_create_shape_surface(surface: Surface, rect: Rect, overlap: int, aa_amount: int, clear: bool = True) Surface

Clear a space for a new shape surface on the main state surface for this state. The surface created will be plain white so that it can be easily multiplied with a colour surface.

Parameters:
  • surface -- The surface we are working on.

  • rect -- Used to size and position the new shape.

  • overlap -- The amount of overlap between this surface and the one below.

  • aa_amount -- The amount of Anti Aliasing to use for this shape.

  • clear -- Whether we should clear our surface.

Returns:

The new shape surface.

collide_point(point: Vector2 | Tuple[int, int] | Tuple[float, float]) bool

Checks collision between a point and this ellipse.

Parameters:

point -- The point to test against the shape.

Returns:

True if the point is inside the shape.

full_rebuild_on_size_change()

Completely redraw the shape from it's theming parameters and dimensions.

redraw_state(state_str: str, add_text: bool = True)

Redraws the shape's surface for a given UI state.

Parameters:
  • add_text -- Whether to add the text to the shape in this redraw.

  • state_str -- The ID string of the state to rebuild.

set_dimensions(dimensions: Vector2 | Tuple[int, int] | Tuple[float, float])

Expensive size change of the ellipse shape.

Parameters:

dimensions -- The new size to set the shape to.

set_position(point: Vector2 | Tuple[int, int] | Tuple[float, float])

Move the shape. Only really impacts the position of the 'click_area' hot spot.

Parameters:

point -- The new position to move it to.

class pygame_gui.core.drawable_shapes.RectDrawableShape(containing_rect: Rect, theming_parameters: Dict[str, Any], states: List[str], manager: IUIManagerInterface, *, allow_text_outside_width_border=True, allow_text_outside_height_border=True, text_x_scroll_enabled=False, editable_text=False)

Bases: DrawableShape

A rectangle shape for UI elements has theming options for a border, a shadow, colour gradients and text.

Parameters:
  • containing_rect -- The layout rectangle that surrounds and controls the size of this shape.

  • theming_parameters -- Various styling parameters that control the final look of the shape.

  • states -- The different UI states the shape can be in. Shapes have different surfaces for each state.

  • manager -- The UI manager.

collide_point(point: Vector2 | Tuple[int, int] | Tuple[float, float]) bool

Tests if a point is colliding with our Drawable shape's 'click area' hot spot.

Parameters:

point -- The point to test.

Returns:

True if we are colliding.

full_rebuild_on_size_change()

Completely rebuilds the rectangle shape from it's dimensions and parameters.

Everything needs rebuilding if we change the size of the containing rectangle.

redraw_state(state_str: str, add_text: bool = True)

Redraws the shape's surface for a given UI state.

Parameters:
  • add_text --

  • state_str -- The ID string of the state to rebuild.

set_dimensions(dimensions: Vector2 | Tuple[int, int] | Tuple[float, float])

Changes the size of the rectangle shape. Relatively expensive to do.

Parameters:

dimensions -- The new dimensions.

set_position(point: Vector2 | Tuple[int, int] | Tuple[float, float])

Move the shape. Only really impacts the position of the 'click_area' hot spot.

Parameters:

point -- The new position to move it to.

class pygame_gui.core.drawable_shapes.RoundedRectangleShape(containing_rect: Rect, theming_parameters: Dict[str, Any], states: List[str], manager: IUIManagerInterface, *, allow_text_outside_width_border=True, allow_text_outside_height_border=True, text_x_scroll_enabled=False, editable_text=False)

Bases: DrawableShape

A drawable rounded rectangle shape for the UI, has theming options for a border, a shadow, colour gradients and text.

Parameters:
  • containing_rect -- The layout rectangle that surrounds and controls the size of this shape.

  • theming_parameters -- Various styling parameters that control the final look of the shape.

  • states -- The different UI states the shape can be in. Shapes have different surfaces for each state.

  • manager -- The UI manager.

clean_up_temp_shapes()

Clean up some temporary surfaces we use repeatedly when rebuilding multiple states of the shape but have no need of afterward.

clear_and_create_shape_surface(surface: Surface, rect: Rect, overlap: int, corner_radii: List[int], aa_amount: int, clear: bool = True) Surface

Clear a space for a new shape surface on the main state surface for this state. The surface created will be plain white so that it can be easily multiplied with a colour surface.

Parameters:
  • surface -- The surface we are working on.

  • rect -- Used to size and position the new shape.

  • overlap -- The amount of overlap between this surface and the one below.

  • corner_radii -- The radii of the rounded corners.

  • aa_amount -- The amount of Anti Aliasing to use for this shape.

  • clear -- Whether we should clear our surface.

Returns:

The new shape surface.

collide_point(point: Vector2 | Tuple[int, int] | Tuple[float, float]) bool

Checks collision between a point and this rounded rectangle.

Parameters:

point -- The point to test collision with.

Returns:

True, if the point is inside the shape.

create_subtract_surface(subtract_size: Tuple[int, int], corner_radii: List[int], aa_amount: int)

Create a rounded rectangle shaped surface that can be used to subtract everything from a surface to leave a transparent hole in it.

static draw_colourless_rounded_rectangle(large_corner_radius: List[int], large_shape_surface: Surface, corner_offset: int = 0)

Draw a rounded rectangle shape in pure white, so it is ready to be multiplied by a colour or gradient.

Parameters:
  • large_corner_radius -- The radius of the corners.

  • large_shape_surface -- The surface to draw onto, the shape fills the surface.

  • corner_offset -- Offsets the corners, used to help avoid overlaps that look bad.

full_rebuild_on_size_change()

Completely rebuilds the rounded rectangle shape from its dimensions and parameters.

Everything needs rebuilding if we change the size of the containing rectangle.

redraw_state(state_str: str, add_text: bool = True)

Redraws the shape's surface for a given UI state.

Parameters:
  • add_text --

  • state_str -- The ID string of the state to rebuild.

set_dimensions(dimensions: Vector2 | Tuple[int, int] | Tuple[float, float])

Changes the size of the rounded rectangle shape. Relatively expensive to completely do so has support for 'temporary rapid resizing' while the dimensions are being changed frequently.

Parameters:

dimensions -- The new dimensions.

set_position(point: Vector2 | Tuple[int, int] | Tuple[float, float])

Move the shape. Only really impacts the position of the 'click_area' hot spot.

Parameters:

point -- The new position to move it to.