2022-12-13 09:20:36 +01:00
|
|
|
function Node_Wrap_Area(_x, _y, _group = -1) : Node_Processor(_x, _y, _group) constructor {
|
2023-01-01 02:06:02 +01:00
|
|
|
name = "Area warp";
|
2022-11-14 03:16:15 +01:00
|
|
|
|
|
|
|
inputs[| 0] = nodeValue(0, "Surface in", self, JUNCTION_CONNECT.input, VALUE_TYPE.surface, 0);
|
|
|
|
inputs[| 1] = nodeValue(1, "Area", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, [ 16, 16, 4, 4, AREA_SHAPE.rectangle ])
|
2022-12-27 04:00:50 +01:00
|
|
|
.setDisplay(VALUE_DISPLAY.area)
|
2022-12-27 13:30:02 +01:00
|
|
|
.setUnitRef(function(index) { return getDimension(index); });;
|
2022-11-14 03:16:15 +01:00
|
|
|
|
|
|
|
outputs[| 0] = nodeValue(0, "Surface out", self, JUNCTION_CONNECT.output, VALUE_TYPE.surface, PIXEL_SURFACE);
|
|
|
|
|
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-01-01 02:06:02 +01:00
|
|
|
static process_data = 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];
|
|
|
|
|
|
|
|
var ww = cw / surface_get_width(_inSurf) * 2;
|
|
|
|
var hh = ch / surface_get_height(_inSurf) * 2;
|
|
|
|
|
|
|
|
surface_set_target(_outSurf);
|
|
|
|
draw_clear_alpha(0, 0);
|
2022-12-27 04:00:50 +01:00
|
|
|
BLEND_OVER
|
2022-11-14 03:16:15 +01:00
|
|
|
|
|
|
|
draw_surface_ext_safe(_inSurf, cx - cw, cy - ch, ww, hh, 0, c_white, 1);
|
|
|
|
|
|
|
|
BLEND_NORMAL
|
|
|
|
surface_reset_target();
|
|
|
|
|
|
|
|
return _outSurf;
|
|
|
|
}
|
|
|
|
}
|