rect

yzheka-m/nokia-5510-display/rect

No description
rect
@/rect
DISPLAY@/display
Display object
POSITION@/point
position of top left corner
WIDTHnumber
Width of the rectangle
HEIGHTnumber
Height of the rectangle
CORNERSnumber
Corners radius
FILLboolean
Fill the rect or not
BLACKboolean
Black or white color
rect
DISPLAY
POSITION
WIDTH
HEIGHT
CORNERS
FILL
BLACK
DONE
DONEpulse
Pulse when rect is placed on screen
To use the node in your project you should have the yzheka-m/nokia-5510-display 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

struct State {
    int x,y,width,height,radius;
    bool fill,black,set=false;
};

{{ GENERATED_CODE }}

void evaluate(Context ctx) {
    auto display = getValue<input_DISPLAY>(ctx);
    auto point = getValue<input_POSITION>(ctx);
    auto state = getState(ctx);
    if(state->set){
        if(state->fill)display->fillRoundRect(state->x,state->y,state->width,state->height,state->radius,state->black?WHITE:BLACK);
        else display->drawRoundRect(state->x,state->y,state->width,state->height,state->radius,state->black?WHITE:BLACK);
    }
    state->x=point->x; state->y=point->y;
    state->width=getValue<input_WIDTH>(ctx);
    state->height=getValue<input_HEIGHT>(ctx);
    state->radius=getValue<input_CORNERS>(ctx);
    state->fill=getValue<input_FILL>(ctx);
    state->black=getValue<input_BLACK>(ctx);
    state->set=true;
    if(state->fill)display->fillRoundRect(state->x,state->y,state->width,state->height,state->radius,state->black?BLACK:WHITE);
    else display->drawRoundRect(state->x,state->y,state->width,state->height,state->radius,state->black?BLACK:WHITE);
    display->display();
    emitValue<output_DONE>(ctx, 1);
}