2023-02-28 09:43:01 +01:00
|
|
|
function Node_Wrap_Area(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) constructor {
|
2023-01-25 06:49:00 +01:00
|
|
|
name = "Area Warp";
|
2022-11-14 03:16:15 +01:00
|
|
|
|
2023-02-14 05:32:32 +01:00
|
|
|
inputs[| 0] = nodeValue("Surface in", self, JUNCTION_CONNECT.input, VALUE_TYPE.surface, 0);
|
2023-10-02 08:57:44 +02:00
|
|
|
|
|
|
|
onSurfaceSize = function() { return getInputData(0, DEF_SURF); };
|
2023-02-14 05:32:32 +01:00
|
|
|
inputs[| 1] = nodeValue("Area", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, [ 16, 16, 4, 4, AREA_SHAPE.rectangle ])
|
2023-10-02 08:57:44 +02:00
|
|
|
.setDisplay(VALUE_DISPLAY.area, { onSurfaceSize });
|
2022-11-14 03:16:15 +01:00
|
|
|
|
2023-02-14 05:32:32 +01:00
|
|
|
inputs[| 2] = nodeValue("Active", self, JUNCTION_CONNECT.input, VALUE_TYPE.boolean, true);
|
|
|
|
active_index = 2;
|
|
|
|
|
|
|
|
outputs[| 0] = nodeValue("Surface out", self, JUNCTION_CONNECT.output, VALUE_TYPE.surface, noone);
|
|
|
|
|
|
|
|
input_display_list = [ 2,
|
2023-05-03 21:42:17 +02:00
|
|
|
["Output", false], 0,
|
2023-02-14 05:32:32 +01:00
|
|
|
["Area", false], 1,
|
|
|
|
]
|
2022-11-14 03:16:15 +01:00
|
|
|
|
2023-03-19 09:17:39 +01:00
|
|
|
attribute_surface_depth();
|
2023-03-21 03:01:53 +01:00
|
|
|
attribute_interpolation();
|
2023-03-19 09:17:39 +01:00
|
|
|
|
2023-09-02 10:43:33 +02:00
|
|
|
attributes[? "initalset"] = false;
|
|
|
|
|
|
|
|
static onValueFromUpdate = function(index) { #region
|
|
|
|
if(index == 0 && attributes[? "initalset"] == false) {
|
2023-10-02 08:57:44 +02:00
|
|
|
var _surf = getInputData(0);
|
2023-09-02 10:43:33 +02:00
|
|
|
if(!is_surface(_surf)) return;
|
|
|
|
|
2023-09-08 21:37:36 +02:00
|
|
|
var _sw = surface_get_width_safe(_surf);
|
|
|
|
var _sh = surface_get_height_safe(_surf);
|
2023-09-02 10:43:33 +02:00
|
|
|
|
|
|
|
inputs[| 1].setValue([ _sw / 2, _sh / 2, _sw / 2, _sh / 2, AREA_SHAPE.rectangle ]);
|
|
|
|
attributes[? "initalset"] = true;
|
|
|
|
}
|
|
|
|
} #endregion
|
|
|
|
|
2022-12-19 13:35:30 +01:00
|
|
|
static drawOverlay = function(active, _x, _y, _s, _mx, _my, _snx, _sny) {
|
|
|
|
inputs[| 1].drawOverlay(active, _x, _y, _s, _mx, _my, _snx, _sny);
|
2022-11-14 03:16:15 +01:00
|
|
|
}
|
|
|
|
|
2023-08-17 16:56:54 +02:00
|
|
|
static processData = function(_outSurf, _data, _output_index, _array_index) {
|
2022-11-14 03:16:15 +01:00
|
|
|
var _inSurf = _data[0];
|
2022-12-27 13:30:02 +01:00
|
|
|
if(!is_surface(_inSurf)) return _outSurf;
|
|
|
|
|
2022-11-14 03:16:15 +01:00
|
|
|
var _area = _data[1];
|
2022-12-27 13:30:02 +01:00
|
|
|
if(!is_array(_area) && array_length(_area) < 4)
|
|
|
|
return _outSurf;
|
2022-11-14 03:16:15 +01:00
|
|
|
|
|
|
|
var cx = _area[0];
|
|
|
|
var cy = _area[1];
|
|
|
|
var cw = _area[2];
|
|
|
|
var ch = _area[3];
|
|
|
|
|
2023-09-08 21:37:36 +02:00
|
|
|
var ww = cw / surface_get_width_safe(_inSurf) * 2;
|
|
|
|
var hh = ch / surface_get_height_safe(_inSurf) * 2;
|
2022-11-14 03:16:15 +01:00
|
|
|
|
2023-03-21 03:01:53 +01:00
|
|
|
surface_set_shader(_outSurf);
|
|
|
|
shader_set_interpolation(_inSurf);
|
|
|
|
draw_surface_ext_safe(_inSurf, cx - cw, cy - ch, ww, hh, 0, c_white, 1);
|
|
|
|
surface_reset_shader();
|
2022-11-14 03:16:15 +01:00
|
|
|
|
|
|
|
return _outSurf;
|
|
|
|
}
|
|
|
|
}
|