text

xod/graphics/text

Represents a text printed with the foreground color.
text
@/text
Represents a text printed with the foreground color.
GFX@/graphics
Xnumber
Left point of the text on the canvas.
SCLnumber
Text scale. A simple point-based magnification algorithm is used, so the value should be an integer greater or equal to 1.
Ynumber
Top point of the text on the canvas.
Sstring
A string to display.
text
GFX'
GFX
X
SCL
Y
S
GFX'@/graphics

C++ implementation

#include <Text.h>

node {
    uint8_t mem[sizeof(Text)];
    Text* text;
    uint8_t _textScale;
    int16_t _x, _y;

    void evaluate(Context ctx) {
        auto gfx = getValue<input_GFX>(ctx);

        int16_t x = (int16_t)getValue<input_X>(ctx);
        int16_t y = (int16_t)getValue<input_Y>(ctx);
        uint8_t textScale = max(1, (int)getValue<input_SCL>(ctx));

        if (isSettingUp()) {
            text = new (mem) Text(gfx);
        }

        if (isSettingUp() || _x != x || _y != y || textScale != _textScale || isInputDirty<input_S>(ctx)) {
            _x = x;
            _y = y;
            _textScale = textScale;
            text->setText(getValue<input_S>(ctx));
            text->setPosition(x, y);
            text->setTextScale(textScale);
            emitValue<output_GFXU0027>(ctx, text);
        }

        if (isInputDirty<input_GFX>(ctx)) {
            emitValue<output_GFXU0027>(ctx, text);
        }
    }
}