Gradient Rectangle¶
- draw_text.add_gradient_rectangle(sx: int, sy: int, w: int, h: int, start_color: int, end_color: int, display_duration: float, layer: int = 1) int¶
Add a gradient rectangle element to the screen.
- Parameters:
sx – X-coordinate of the upper-left corner.
sy – Y-coordinate of the upper-left corner.
w – Width of the rectangle.
h – Height of the rectangle.
start_color – Color at the top of the rectangle. Must be created by the [argb]() function or from the [Colors]() class.
end_color – Color at the bottom of the rectangle. Must be created by the [argb]() function or 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_gradient_rectangle(_id: int, func: Callable[[GradientRectangleObject], None]) None¶
Animates the gradient rectangle element with the given id by calling the given function every frame with the gradient rectangle element as the argument.
- Parameters:
_id – ID of the gradient rectangle element to animate.
func – Function to use to animate the gradient rectangle element. The function is called every frame with the gradient rectangle element as the argument.
- draw_text.modify_gradient_rectangle(_id: int, func: Callable[[GradientRectangleObject], None]) None¶
Modifies the gradient rectangle element with the given id by calling the given function once with the gradient rectangle element as the argument.
- Parameters:
_id – ID of the gradient rectangle element to modify.
func – Function to use to modify the gradient rectangle element. The function is called on the closest render frame.
GradientRectangleObject class¶
- class draw_text.GradientRectangleObject(_id: int)¶
- start_x: int¶
X-coordinate of the upper-left corner.
- start_y: int¶
Y-coordinate of the upper-left corner.
- end_x: int¶
X-coordinate of the bottom-right corner.
- end_y: int¶
Y-coordinate of the bottom-right corner.
- start_color: int¶
Color at the top of the rectangle. Must be created by the [argb]() function or from the [Colors]() class.
- end_color: int¶
Color at the bottom of the rectangle. Must be created by the [argb]() function or from the [Colors]() class.
- display_duration_modifier: float¶
Modifier to the
display_durationproperty.
- 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_modifierto change this value.
- update(_id: int)¶
Updates this GradientRectangleObject with the values of the gradient rectangle element specified by _id.
- Parameters:
_id – ID of the gradient rectangle element.
- to_list() list¶
Returns a list containing all the values of this GradientRectangleObject.
- Returns:
List containing all the values of this GradientRectangleObject.
Example¶
1from draw_text import *
2
3def move(r:GradientRectangleObject):
4 r.start_x+=1
5 r.end_x+=1
6
7rect_id = add_gradient_rectangle(sx=10, sy=10, w=50, h=20, start_color=Colors.RED, end_color=Colors.YELLOW, display_duration=5)
8
9animate_gradient_rectangle(rect_id, move)