draw-text

wayland/vidor-graphics/draw-text

Draw text.
draw-text
@/draw-text
Draw text.
GFX@/gfx-device
A Vidor graphics device.
Xnumber
X coordinate.
Ynumber
Y coordinate.
Textstring
Text string.
Sizenumber
Font size.
Fontnumber
Font index.
Colorxod/color/color
Color of text.
Alphanumber
Alpha compositing. Takes a value from 0 to 255.
UPDpulse
Update
draw-text
GFX
X
Y
Text
Size
Font
Color
Alpha
UPD
Done
Donepulse
Pulse on completion.
To use the node in your project you should have the wayland/vidor-graphics library installed. Use the “File → Add Library” menu item in XOD IDE if you don’t have it yet. See Using libraries for more info.

C++ implementation

#pragma XOD evaluate_on_pin disable
#pragma XOD evaluate_on_pin enable input_UPD

node {
    void evaluate(Context ctx) {

        if (!isInputDirty<input_UPD>(ctx))
            return;

        auto gfx = getValue<input_GFX>(ctx);

        auto xString = getValue<input_Text>(ctx);
        int N=length(xString) + 1;
        char cString[N];
        for(int i=0;i<N;i++)
        cString[i]=0;
        dump(xString, cString);

        auto color = getValue<input_Color>(ctx);
        uint32_t color32 = gfx->Color(color.r, color.g, color.b);

        gfx->text.setCursor(
            getValue<input_X>(ctx),
            getValue<input_Y>(ctx));
        gfx->text.setAlpha(getValue<input_Alpha>(ctx));
        gfx->text.setSize(getValue<input_Size>(ctx));
        gfx->setFont(getValue<input_Font>(ctx));
        gfx->text.setColor(color32);
        gfx->println(cString);

        emitValue<output_Done>(ctx, 1);
    }
}