2023-02-28 09:43:01 +01:00
|
|
|
function Node_Area(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) constructor {
|
2023-12-03 05:02:04 +01:00
|
|
|
name = "Area";
|
2022-11-18 03:20:31 +01:00
|
|
|
color = COLORS.node_blend_number;
|
2024-05-02 11:05:02 +02:00
|
|
|
setDimension(96, 48);
|
2023-01-17 08:11:55 +01:00
|
|
|
|
2024-08-08 06:57:51 +02:00
|
|
|
inputs[0] = nodeValue_Vector("Position", self, [ 0, 0 ] )
|
2022-11-01 03:06:03 +01:00
|
|
|
.setVisible(true, true);
|
2024-07-08 06:19:13 +02:00
|
|
|
|
2024-08-08 06:57:51 +02:00
|
|
|
inputs[1] = nodeValue_Vector("Span", self, [ 16, 16 ] )
|
2022-11-01 03:06:03 +01:00
|
|
|
.setVisible(true, true);
|
2022-01-13 05:24:03 +01:00
|
|
|
|
2024-08-08 06:57:51 +02:00
|
|
|
inputs[2] = nodeValue_Enum_Scroll("Shape", self, AREA_SHAPE.rectangle, [
|
2024-08-07 11:48:39 +02:00
|
|
|
new scrollItem("Rectangle", s_node_shape_rectangle, 0),
|
|
|
|
new scrollItem("Elipse", s_node_shape_circle, 0)
|
|
|
|
]);
|
2022-01-13 05:24:03 +01:00
|
|
|
|
2024-08-08 06:57:51 +02:00
|
|
|
inputs[3] = nodeValue_Enum_Scroll("Type", self, 0, [ "Center Span", "Two Point" ]);
|
2024-07-08 06:19:13 +02:00
|
|
|
|
2024-08-08 06:57:51 +02:00
|
|
|
outputs[0] = nodeValue_Output("Area", self, VALUE_TYPE.float, [ 0, 0, 0, 0, AREA_SHAPE.rectangle ])
|
2022-01-13 05:24:03 +01:00
|
|
|
.setDisplay(VALUE_DISPLAY.vector);
|
|
|
|
|
2024-07-08 06:19:13 +02:00
|
|
|
input_display_list = [ 3,
|
|
|
|
["Positions", false], 0, 1, 2,
|
|
|
|
]
|
|
|
|
|
2024-03-14 14:35:19 +01:00
|
|
|
static drawOverlay = function(hover, active, _x, _y, _s, _mx, _my, _snx, _sny) {
|
2024-05-10 04:01:14 +02:00
|
|
|
PROCESSOR_OVERLAY_CHECK
|
2023-08-24 11:59:05 +02:00
|
|
|
|
2024-07-08 06:19:13 +02:00
|
|
|
var _shape = current_data[2];
|
|
|
|
var _type = current_data[3];
|
|
|
|
var _hov = hover;
|
|
|
|
var _hhh = false;
|
|
|
|
var hv;
|
|
|
|
|
|
|
|
if(_type == 0) {
|
|
|
|
var _pos = current_data[0];
|
|
|
|
var _span = current_data[1];
|
2022-01-13 05:24:03 +01:00
|
|
|
|
2024-07-08 06:19:13 +02:00
|
|
|
var px = _x + _pos[0] * _s;
|
|
|
|
var py = _y + _pos[1] * _s;
|
|
|
|
var ex = _span[0] * _s;
|
|
|
|
var ey = _span[1] * _s;
|
|
|
|
|
|
|
|
draw_set_color(COLORS._main_accent);
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2024-08-08 06:57:51 +02:00
|
|
|
hv = inputs[0].drawOverlay(_hov, active, _x, _y, _s, _mx, _my, _snx, _sny); _hhh |= hv; _hov &= !hv;
|
|
|
|
hv = inputs[1].drawOverlay(_hov, active, px, py, _s, _mx, _my, _snx, _sny); _hhh |= hv; _hov &= !hv;
|
2024-07-08 06:19:13 +02:00
|
|
|
|
|
|
|
} else if(_type == 1) {
|
|
|
|
var _v0 = current_data[0];
|
|
|
|
var _v1 = current_data[1];
|
|
|
|
|
|
|
|
var px = _x + _v0[0] * _s;
|
|
|
|
var py = _y + _v0[1] * _s;
|
|
|
|
var ex = _x + _v1[0] * _s;
|
|
|
|
var ey = _y + _v1[1] * _s;
|
|
|
|
|
|
|
|
draw_set_color(COLORS._main_accent);
|
|
|
|
switch(_shape) {
|
|
|
|
case AREA_SHAPE.rectangle : draw_rectangle(px, py, ex, ey, true); break;
|
|
|
|
case AREA_SHAPE.elipse : draw_ellipse(px, py, ex, ey, true); break;
|
|
|
|
}
|
|
|
|
|
2024-08-08 06:57:51 +02:00
|
|
|
hv = inputs[0].drawOverlay(_hov, active, _x, _y, _s, _mx, _my, _snx, _sny); _hhh |= hv; _hov &= !hv;
|
|
|
|
hv = inputs[1].drawOverlay(_hov, active, _x, _y, _s, _mx, _my, _snx, _sny); _hhh |= hv; _hov &= !hv;
|
2022-01-13 05:24:03 +01:00
|
|
|
}
|
2024-07-08 06:19:13 +02:00
|
|
|
|
|
|
|
return _hhh;
|
2022-01-13 05:24:03 +01:00
|
|
|
}
|
|
|
|
|
2024-07-08 06:19:13 +02:00
|
|
|
static processData = function(_output, _data, _output_index, _array_index = 0) {
|
|
|
|
var _v0 = _data[0];
|
|
|
|
var _v1 = _data[1];
|
|
|
|
var _shap = _data[2];
|
|
|
|
var _type = _data[3];
|
|
|
|
|
|
|
|
if(_type == 0) {
|
2024-08-08 06:57:51 +02:00
|
|
|
inputs[0].setName("Position");
|
|
|
|
inputs[1].setName("Span");
|
2024-07-08 06:19:13 +02:00
|
|
|
|
|
|
|
return [ _v0[0], _v0[1], _v1[0], _v1[1], _shap ];
|
|
|
|
|
|
|
|
} else if(_type == 1) {
|
2024-08-08 06:57:51 +02:00
|
|
|
inputs[0].setName("Point 1");
|
|
|
|
inputs[1].setName("Point 2");
|
2024-07-08 06:19:13 +02:00
|
|
|
|
|
|
|
var xc = ( _v0[0] + _v1[0] ) / 2;
|
|
|
|
var yc = ( _v0[1] + _v1[1] ) / 2;
|
|
|
|
var ww = abs(_v1[0] - _v0[0]) / 2;
|
|
|
|
var hh = abs(_v1[1] - _v0[1]) / 2;
|
|
|
|
|
|
|
|
return [ xc, yc, ww, hh, _shap ];
|
|
|
|
}
|
|
|
|
|
|
|
|
return [ _v0[0], _v0[1], _v1[0], _v1[1], _shap ];
|
2022-01-13 05:24:03 +01:00
|
|
|
}
|
|
|
|
|
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
|
|
|
}
|
|
|
|
}
|