triangle-outline-colored

xod/graphics/triangle-outline-colored

Represents a triangle with a custom style.
triangle-outline-colored
@/triangle-outline-colored
Represents a triangle with a custom style.
GFX@/graphics
Cxod/color/color
Triangle color.
X0number
X coordinate of the first point of the triangle on the canvas.
Y0number
Y coordinate of the first point of the triangle on the canvas.
Y1number
Y coordinate of the second point of the triangle on the canvas.
X1number
X coordinate of the second point of the triangle on the canvas.
X2number
X coordinate of the third point of the triangle on the canvas.
Y2number
Y coordinate of the third point of the triangle on the canvas.
triangle-outline-colored
GFX
C
X0
Y0
Y1
X1
X2
Y2
GFX'
GFX'@/graphics

C++ implementation

#include <Triangle.h>
node {
    uint8_t mem[sizeof(TriangleOutline)];
    TriangleOutline* triangleOutlineColored;
    int16_t _x0, _y0, _x1, _y1, _x2, _y2;
    XColor strokeColor;

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

        int16_t x0 = (int16_t)getValue<input_X0>(ctx);
        int16_t y0 = (int16_t)getValue<input_Y0>(ctx);
        int16_t x1 = (int16_t)getValue<input_X1>(ctx);
        int16_t y1 = (int16_t)getValue<input_Y1>(ctx);
        int16_t x2 = (int16_t)getValue<input_X2>(ctx);
        int16_t y2 = (int16_t)getValue<input_Y2>(ctx);

        if (isSettingUp()) {
            triangleOutlineColored = new (mem) TriangleOutline(gfx);
        }

        if (isSettingUp() || x0 != _x0 || y0 != _y0 || x1 != _x1 || y1 != _y1 || x2 != _x2 || y2 != _y2 || isInputDirty<input_C>(ctx)) {
            _x0 = x0;
            _y0 = y0;
            _x1 = x1;
            _y1 = y1;
            _x2 = x2;
            _y2 = y2;
            triangleOutlineColored->setPosition(x0, y0, x1, y1, x2, y2);
            triangleOutlineColored->setStyle(&strokeColor);
            emitValue<output_GFXU0027>(ctx, triangleOutlineColored);
        }

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