2023-02-28 09:43:01 +01:00
|
|
|
function Node_Area(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) constructor {
|
2022-01-13 05:24:03 +01:00
|
|
|
name = "Area";
|
2022-11-18 03:20:31 +01:00
|
|
|
color = COLORS.node_blend_number;
|
2022-01-13 05:24:03 +01:00
|
|
|
previewable = false;
|
|
|
|
|
|
|
|
w = 96;
|
2023-01-17 08:11:55 +01:00
|
|
|
|
2022-01-13 05:24:03 +01:00
|
|
|
|
2023-02-14 05:32:32 +01:00
|
|
|
inputs[| 0] = nodeValue("Postion", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, [ 0, 0 ] )
|
2022-11-01 03:06:03 +01:00
|
|
|
.setDisplay(VALUE_DISPLAY.vector)
|
|
|
|
.setVisible(true, true);
|
2023-02-14 05:32:32 +01:00
|
|
|
inputs[| 1] = nodeValue("Size", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, [ 16, 16 ] )
|
2022-11-01 03:06:03 +01:00
|
|
|
.setDisplay(VALUE_DISPLAY.vector)
|
|
|
|
.setVisible(true, true);
|
2022-01-13 05:24:03 +01:00
|
|
|
|
2023-02-14 05:32:32 +01:00
|
|
|
inputs[| 2] = nodeValue("Shape", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, AREA_SHAPE.rectangle )
|
2022-01-13 05:24:03 +01:00
|
|
|
.setDisplay(VALUE_DISPLAY.enum_scroll, ["Rectangle", "Elipse"]);
|
|
|
|
|
2023-02-14 05:32:32 +01:00
|
|
|
outputs[| 0] = nodeValue("Area", self, JUNCTION_CONNECT.output, VALUE_TYPE.float, [ 0, 0, 0, 0, AREA_SHAPE.rectangle ])
|
2022-01-13 05:24:03 +01:00
|
|
|
.setDisplay(VALUE_DISPLAY.vector);
|
|
|
|
|
2022-12-19 13:35:30 +01:00
|
|
|
static drawOverlay = function(active, _x, _y, _s, _mx, _my, _snx, _sny) {
|
2023-08-24 11:59:05 +02:00
|
|
|
if(process_amount > 1) return;
|
|
|
|
|
|
|
|
var _pos = getInputData(0);
|
|
|
|
var _span = getInputData(1);
|
|
|
|
var _shape = getInputData(2);
|
2022-01-13 05:24:03 +01:00
|
|
|
var px = _x + _pos[0] * _s;
|
|
|
|
var py = _y + _pos[1] * _s;
|
|
|
|
var ex = _span[0] * _s;
|
|
|
|
var ey = _span[1] * _s;
|
|
|
|
|
2022-11-18 03:20:31 +01:00
|
|
|
draw_set_color(COLORS._main_accent);
|
2022-01-13 05:24:03 +01:00
|
|
|
switch(_shape) {
|
|
|
|
case AREA_SHAPE.rectangle :
|
|
|
|
draw_rectangle(px - ex, py - ey, px + ex, py + ey, true);
|
|
|
|
break;
|
|
|
|
case AREA_SHAPE.elipse :
|
|
|
|
draw_ellipse(px - ex, py - ey, px + ex, py + ey, true);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2022-12-19 13:35:30 +01:00
|
|
|
inputs[| 0].drawOverlay(active, _x, _y, _s, _mx, _my, _snx, _sny);
|
|
|
|
inputs[| 1].drawOverlay(active, px, py, _s, _mx, _my, _snx, _sny);
|
2022-01-13 05:24:03 +01:00
|
|
|
}
|
|
|
|
|
2023-08-17 16:56:54 +02:00
|
|
|
static processData = function(_output, _data, _output_index, _array_index = 0) {
|
2022-01-13 05:24:03 +01:00
|
|
|
return [_data[0][0], _data[0][1], _data[1][0], _data[1][1], _data[2]];
|
|
|
|
}
|
|
|
|
|
2023-03-05 07:16:44 +01:00
|
|
|
static onDrawNode = function(xx, yy, _mx, _my, _s, _hover, _focus) {
|
2023-01-04 02:30:04 +01:00
|
|
|
var bbox = drawGetBbox(xx, yy, _s);
|
|
|
|
draw_sprite_fit(THEME.node_draw_area, 0, bbox.xc, bbox.yc, bbox.w, bbox.h);
|
2022-01-13 05:24:03 +01:00
|
|
|
}
|
|
|
|
}
|