Stroked Rectangle

Warning

Only in versions 1.21.10 and up!

draw_text.add_stroked_rectangle(x: int, y: int, w: int, h: int, color: int, display_duration: float, layer: int = 1) int

Add a stroked (outline) rectangle element to the screen.

Parameters:
  • x – X-coordinate of the upper-left corner.

  • y – Y-coordinate of the upper-left corner.

  • w – Width of the rectangle.

  • h – Height of the rectangle.

  • color – Rectangle color. Must be created with argb(…) or taken from the Colors class.

  • display_duration – How long the element remains on screen (in seconds).

  • layer – Rendering layer of the element. Higher layers appear above lower ones. Default is 1.

Returns:

ID of the created element.

draw_text.animate_stroked_rectangle(_id: int, func: Callable[[StrokedRectangleObject], None]) None

Animates the stroked rectangle element with the given id by calling the given function every frame with the stroked rectangle element as the argument.

Parameters:
  • _id – ID of the stroked rectangle element to animate.

  • func – Function to use to animate the stroked rectangle element. The function is called every frame with the stroked rectangle element as the argument.

draw_text.modify_stroked_rectangle(_id: int, func: Callable[[StrokedRectangleObject], None]) None

Modifies the stroked rectangle element with the given id by calling the given function once with the stroked rectangle element as the argument.

Parameters:
  • _id – ID of the stroked rectangle element to modify.

  • func – Function to use to modify the stroked rectangle element. The function is called on the closest render frame.


StrokedRectangleObject class

class draw_text.StrokedRectangleObject(_id: int)
x: int

X-coordinate of the upper-left corner.

y: int

Y-coordinate of the upper-left corner.

width: int

Width of the rectangle.

height: int

Height of the rectangle.

color: int

Rectangle color. Must be created by the [argb]() function or from the [Colors]() class.

display_duration_modifier: float

Modifier to the display_duration property.

layer: int

Layer of the element.

property display_duration

Time in seconds that the element will remain on screen. This property cannot be assigned, use display_duration_modifier to change this value.

update(_id: int)

Updates this StrokedRectangleObject with the values of the rectangle element specified by _id.

Parameters:

_id – ID of the rectangle element.

to_list() list

Returns a list containing all the values of this StrokedRectangleObject.

Returns:

List containing all the values of this StrokedRectangleObject.

Example

1from draw_text import *
2
3def move(r:StrokedRectangleObject):
4    r.start_x+=1
5    r.end_x+=1
6
7rect_id = add_stroked_rectangle(x=10, y=10, w=50, h=20, color=Colors.RED, display_duration=5)
8
9animate_stroked_rectangle(rect_id, move)