Bitbybit Docs
    Preparing search index...

    Class BabylonGuiTextBlock

    Text labels: a block of text with a color, font size, alignment, optional outline, wrapping and line spacing. Use one for titles and readouts next to other controls.

    Index

    Constructors

    create

    • Creates a block of text with a color and font size; sizes are pixel strings or fractions of the parent, and a size left out is chosen by the engine.

      Parameters

      • inputs: CreateTextBlockDto

        The name, the text, the color, the optional size and the font size

      Returns TextBlock

      The text block

      const title = bitbybit.babylon.gui.textBlock.createTextBlock({ name: "title", text: "Radius", color: "#f0cebb", width: "300px", height: "40px", fontSize: 24 });
      panel.addControl(title);

    get

    • Reads the text a text block currently shows.

      Parameters

      Returns string

      The text

    • Reads how a text block handles text wider than itself.

      Parameters

      Returns any

      The wrapping mode

    • Reads the extra space between the lines of a text block.

      Parameters

      Returns string | number

      The line spacing

    • Reads the width of the outline around a text block's letters, 0 meaning none.

      Parameters

      Returns number

      The outline width

    • Reads whether a text block resizes itself to fit its text.

      Parameters

      Returns boolean

      True when it resizes to fit

    • Reads where the text sits horizontally in its block, as the engine's number for left, center or right.

      Parameters

      Returns number

      The horizontal alignment code

    • Reads where the text sits vertically in its block, as the engine's number for top, center or bottom.

      Parameters

      Returns number

      The vertical alignment code

    positioning

    • Sets where the text sits inside its block: left, center or right, and top, center or bottom.

      Parameters

      • inputs: AlignmentDto<TextBlock>

        The text block and the two alignments

      Returns TextBlock

      The same text block

      bitbybit.babylon.gui.textBlock.alignText({ control: title, horizontalAlignment: Bit.Inputs.BabylonGui.horizontalAlignmentEnum.left, verticalAlignment: Bit.Inputs.BabylonGui.verticalAlignmentEnum.center });
      

    set

    • Draws an outline around the letters of a text block, outlineWidth pixels wide in outlineColor, which keeps text readable over a busy scene; 0 removes it.

      Parameters

      Returns TextBlock

      The same text block

      bitbybit.babylon.gui.textBlock.setTextOutline({ textBlock: title, outlineWidth: 2, outlineColor: "black" });
      
    • Changes the text a text block shows to the given text.

      Parameters

      Returns TextBlock

      The same text block

      bitbybit.babylon.gui.textBlock.setText({ textBlock: readout, text: "Radius: 7.5" });
      
    • Lets a text block grow or shrink to fit its text, when true, instead of keeping its set size.

      Parameters

      Returns TextBlock

      The same text block

    • Sets how a text block handles text wider than itself: wrap onto new lines when true, clip when false, or one of the engine's wrapping modes such as ellipsis.

      Parameters

      Returns TextBlock

      The same text block

    • Sets the extra space between the lines of a wrapped text block, as pixels or a string such as 4px.

      Parameters

      Returns TextBlock

      The same text block