Texture

draw_text.add_texture(texture: Identifier, x: int, y: int, width: int, height: int, alpha: float, display_duration: float, layer: int = 1) int

Add a texture element to the screen.

To add custom textures see Adding Custom Textures.

Parameters:
  • texture – Identifier of the texture. See Identifier for more information.

  • x – X-coordinate of the texture position.

  • y – Y-coordinate of the texture position.

  • width – Width of the texture.

  • height – Height of the texture

  • alpha – Transparency value of the texture. Use alpha_from_int() to create.

  • 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.add_advanced_texture(texture: Identifier, x: int, y: int, width: int, height: int, alpha: float, display_duration: float, layer: int, matrix: Matrix) int

Add a texture element to the screen, with additional scaling, rotation, and translation options.

To add custom textures see Adding Custom Textures.

Advanced version of add_texture() that allows custom transformations.

Parameters:
  • texture – Identifier of the texture. See Identifier for more information.

  • x – X-coordinate of the texture position.

  • y – Y-coordinate of the texture position.

  • width – Width of the texture.

  • height – Height of the texture

  • alpha – Transparency value of the texture. Use alpha_from_int() to create.

  • 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.

  • matrix – Transformation matrix applied to the element (scale, rotation, translation). See Matrix.

Returns:

ID of the created element.

draw_text.animate_texture(_id: int, func: Callable[[TextureObject], None]) None

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

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

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

draw_text.modify_texture(_id: int, func: Callable[[TextureObject], None]) None

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

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

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


TextureObject class

class draw_text.TextureObject(_id: int)
texture: Identifier

Identifier of the texture. See Identifier for more information.

x: int

X-coordinate of the texture.

y: int

Y-coordinate of the texture.

width: int

Width of the texture.

height: int

Height of the texture.

alpha

Transparency value of the texture. Use alpha_from_int() to create.

display_duration_modifier: float

Modifier to the display_duration property.

layer: int

Layer of the element.

matrix: Matrix

Transformation matrix applied to the element (scale, rotation, translation).

property display_duration

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

update(_id: int)

Updates this TextureObject with the values of the texture element specified by _id.

Parameters:

_id – ID of the texture element.

to_list() list

Returns a list containing all the values of this TextureObject.

Returns:

List containing all the values of this TextureObject.


Example

 1from draw_text import *
 2
 3def move(t:TextureObject):
 4    t.x+=1
 5
 6# Uses minecraft texture `hardcore_full.png` found in the `assets/minecraft/textures/gui/sprites/hud/heart/` folder.
 7add_texture(Identifier("hud/heart/hardcore_full", vanilla=True), x=10, y=16, width=9, height=9, alpha=alpha_from_int(255), display_duration=5)
 8
 9# Uses custom texture `red_rectangle.png` added by a resource pack in the `assets/minescripthud/textures/gui/sprites/` folder.
10add_texture(Identifier("red_rectangle", vanilla=False), x=10, y=32, width=10, height=10, alpha=alpha_from_int(255), display_duration=5)
11
12# Supports animated textures
13add_texture(Identifier("icon/music_notes", vanilla=True), x=10, y=48, width=16, height=16, alpha=alpha_from_int(255), display_duration=5)
14
15add_advanced_texture(Identifier("icon/search", vanilla=True), x=10, y=80, width=12, height=12, alpha=alpha_from_int(255), display_duration=5, matrix=Matrix().scale(2))
16
17texture_id = add_texture(Identifier("icon/accessibility", vanilla=True), x=10, y=160, width=15, height=15, alpha=alpha_from_int(255), display_duration=5)
18
19animate_texture(texture_id, move)