Skip to content

Text Box

Make Games Fast Screenshot

Overview

Draw a rectangle into your games canvas that contains text. Wrap, align, and position the textbox by using the text_box! macro.

API

text_box!

Draws a text box with the ability to align, wrap, and position text

text_box!(
    &str,
    font = &str,
    scale = f32,
    start = usize,
    end = usize,
    width = u32,
    height = u32,
    x = i32,
    y = i32,
    color = u32,
    align = &str,
)
ParamTypeDefaultDescription
-&str-Text to be displayed
font&str"medium"Size to display text in: "small", "medium", or "large"
scalef321.0Line spacing and scale of text box
startusize0Starting character to be displayed
endusizetext.len()Ending character to be displayed, defaults to entire text
widthu320Width of the text box in pixels
heightu320Height of the text box in pixels
xi320Starting x position of the text
yi320Starting y position of the text
coloru320xffffffffHex color to display text in
align&str"left"Text allignment in: "left", "center", or "right"

Usage

Basic Usage

    text_box!(
        "Welcome to Turbo!",
        font = "medium",
        width = 50,
        height = 20,
    );
Preview

Welcome To Turbo

Advanced Usage

Wrap and adjust the text_box by declaring different width, height, and align values. Position it with different x and y values:

    text_box!(
        "Turbo makes UI elements easy and fast!",
        font = "medium",
        scale = 1.2,
        start = 0,
        end = 100,
        width = 100,
        height = 80,
        x = 80,
        y = 40,
        align = "center",
        color = 0x000000ff
    );

Turbo Makes UI Easy Screenshot