draw-rectangle

wayland/vidor-graphics/draw-rectangle

Draw a rectangle.
draw-rectangle
@/draw-rectangle
Draw a rectangle.
GFX@/gfx-device
A Vidor graphics device.
Xnumber
Top left corner x coordinate.
Ynumber
Top left corner y coordinate.
Wnumber
Width in pixels.
Hnumber
Height in pixels.
Colorxod/color/color
Color of rectangle.
Alphanumber
Alpha compositing. Takes a value from 0 to 255.
Fillboolean
TRUE to fill rectangle with colour, FALSE to draw outline only.
UPDpulse
Update
draw-rectangle
GFX
X
Y
W
H
Color
Alpha
Fill
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 color = getValue<input_Color>(ctx);
        uint32_t color32 = gfx->Color(color.r, color.g, color.b);
        if (getValue<input_Fill>(ctx)){
            gfx->fillRect(
            getValue<input_X>(ctx),
            getValue<input_Y>(ctx),
            getValue<input_W>(ctx),
            getValue<input_H>(ctx),
            color32,
            getValue<input_Alpha>(ctx));
        } else {
            gfx->drawRect(
            getValue<input_X>(ctx),
            getValue<input_Y>(ctx),
            getValue<input_W>(ctx),
            getValue<input_H>(ctx),
            color32,
            getValue<input_Alpha>(ctx)
            );
        }
        emitValue<output_Done>(ctx, 1);
    }
}