generate-grid

wayland/generate-grid/generate-grid

Calculate the coordinates of all rectangles in a user specified grid.
generate-grid
@/generate-grid
Calculate the coordinates of all rectangles in a user specified grid.
X-startnumber
X coordinate of the left hand side of the grid.
X-stopnumber
X coordinate of the right hand side of the grid. Should be greater than X-start.
X-stepnumber
Horizontal spacing between elements in grid.
Y-startnumber
Y coordinate of the top of the grid.
Y-stopnumber
Y coordinate of the bottom of the grid. Should be greater than Y-start.
Y-stepnumber
Vertical spacing between elements in grid.
UPDpulse
Update. Begin generation of new grid coordinates.
generate-grid
X-start
X-stop
X-step
Y-start
Y-stop
Y-step
UPD
X
Y
Next
Done
Donepulse
Pulse when all grid coordinates have been output.
Nextpulse
Pulse on output of each new pair of coordinates.
Ynumber
Y coordinate of grid element.
Xnumber
X coordinate of grid element.
To use the node in your project you should have the wayland/generate-grid 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

node {
    // Internal state variables defined at this level persists across evaluations
    Number xStart;
    Number xStop;
    Number xStep;
    Number yStart;
    Number yStop;
    Number yStep;
    Number x;
    Number y;
    bool update;
    
    void evaluate(Context ctx) {
        if(isInputDirty<input_UPD>(ctx)) {
            xStart = getValue<input_X_start>(ctx);
            xStop = getValue<input_X_stop>(ctx);
            xStep = getValue<input_X_step>(ctx);
            yStart = getValue<input_Y_start>(ctx);
            yStop = getValue<input_Y_stop>(ctx);
            yStep = getValue<input_Y_step>(ctx);
            x = xStart;
            y = yStart;
            update = true;
        }

        if(update) {
            if (x <= xStop && y <= yStop) {
                emitValue<output_X>(ctx, x);
                emitValue<output_Y>(ctx, y);
                emitValue<output_Next>(ctx, 1);
                x += xStep;
                setImmediate();
            }
            else if (x > xStop && y <= yStop) {
                x = xStart;
                y += yStep;
                setImmediate();
            } else {
                update = false;
                emitValue<output_Done>(ctx, 1);
            }
        }
    }
}