2022-01-13 05:24:03 +01:00
|
|
|
enum NODE_SHAPE_TYPE {
|
|
|
|
rectangle,
|
|
|
|
elipse,
|
|
|
|
regular,
|
|
|
|
star,
|
2023-01-17 08:11:55 +01:00
|
|
|
arc,
|
|
|
|
teardrop,
|
|
|
|
cross,
|
|
|
|
leaf
|
2022-01-13 05:24:03 +01:00
|
|
|
}
|
|
|
|
|
2023-02-28 09:43:01 +01:00
|
|
|
function Node_Shape(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) constructor {
|
2022-01-13 05:24:03 +01:00
|
|
|
name = "Shape";
|
|
|
|
|
2023-07-21 12:40:20 +02:00
|
|
|
inputs[| 0] = nodeValue("Dimension", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, DEF_SURF )
|
2022-01-13 05:24:03 +01:00
|
|
|
.setDisplay(VALUE_DISPLAY.vector);
|
|
|
|
|
2023-03-07 14:29:47 +01:00
|
|
|
inputs[| 1] = nodeValue("Background", self, JUNCTION_CONNECT.input, VALUE_TYPE.boolean, false);
|
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.integer, 0)
|
2023-01-17 08:11:55 +01:00
|
|
|
.setDisplay(VALUE_DISPLAY.enum_scroll, [ "Rectangle", "Ellipse", "Regular polygon", "Star", "Arc", "Teardrop", "Cross", "Leaf" ]);
|
2022-01-13 05:24:03 +01:00
|
|
|
|
2023-11-24 10:41:53 +01:00
|
|
|
onSurfaceSize = function() { return getInputData(0, DEF_SURF); };
|
2023-07-21 12:40:20 +02:00
|
|
|
inputs[| 3] = nodeValue("Position", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, [ DEF_SURF_W / 2, DEF_SURF_H / 2, DEF_SURF_W / 2, DEF_SURF_H / 2, AREA_SHAPE.rectangle ])
|
2023-10-02 08:57:44 +02:00
|
|
|
.setDisplay(VALUE_DISPLAY.area, { onSurfaceSize });
|
2022-01-13 05:24:03 +01:00
|
|
|
|
2023-02-14 05:32:32 +01:00
|
|
|
inputs[| 4] = nodeValue("Sides", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, 3)
|
2022-01-19 03:05:13 +01:00
|
|
|
.setVisible(false);
|
2022-01-13 05:24:03 +01:00
|
|
|
|
2023-02-14 05:32:32 +01:00
|
|
|
inputs[| 5] = nodeValue("Inner radius", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, 0.5)
|
2023-10-02 08:57:44 +02:00
|
|
|
.setDisplay(VALUE_DISPLAY.slider)
|
2022-01-13 05:24:03 +01:00
|
|
|
.setVisible(false);
|
|
|
|
|
2023-02-14 05:32:32 +01:00
|
|
|
inputs[| 6] = nodeValue("Anti alising", self, JUNCTION_CONNECT.input, VALUE_TYPE.boolean, false);
|
2022-01-19 03:05:13 +01:00
|
|
|
|
2023-02-14 05:32:32 +01:00
|
|
|
inputs[| 7] = nodeValue("Rotation", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, 0)
|
2022-01-13 05:24:03 +01:00
|
|
|
.setDisplay(VALUE_DISPLAY.rotation);
|
|
|
|
|
2023-02-14 05:32:32 +01:00
|
|
|
inputs[| 8] = nodeValue("Angle range", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, [ 0, 180 ])
|
2022-01-13 05:24:03 +01:00
|
|
|
.setDisplay(VALUE_DISPLAY.rotation_range);
|
|
|
|
|
2023-02-14 05:32:32 +01:00
|
|
|
inputs[| 9] = nodeValue("Corner radius", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, 0)
|
2023-10-02 08:57:44 +02:00
|
|
|
.setDisplay(VALUE_DISPLAY.slider, { range: [0, 0.5, 0.01] });
|
2022-01-13 05:24:03 +01:00
|
|
|
|
2023-02-14 05:32:32 +01:00
|
|
|
inputs[| 10] = nodeValue("Shape color", self, JUNCTION_CONNECT.input, VALUE_TYPE.color, c_white);
|
2022-08-30 07:36:37 +02:00
|
|
|
|
2023-02-14 05:32:32 +01:00
|
|
|
inputs[| 11] = nodeValue("Background color", self, JUNCTION_CONNECT.input, VALUE_TYPE.color, c_black);
|
2022-01-13 05:24:03 +01:00
|
|
|
|
2023-02-14 05:32:32 +01:00
|
|
|
inputs[| 12] = nodeValue("Height", self, JUNCTION_CONNECT.input, VALUE_TYPE.boolean, false);
|
2022-12-12 09:08:03 +01:00
|
|
|
|
2023-02-14 05:32:32 +01:00
|
|
|
inputs[| 13] = nodeValue("Start radius", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, 0.1)
|
2023-10-02 08:57:44 +02:00
|
|
|
.setDisplay(VALUE_DISPLAY.slider)
|
2023-01-17 08:11:55 +01:00
|
|
|
.setVisible(false);
|
2023-02-14 05:32:32 +01:00
|
|
|
|
|
|
|
inputs[| 14] = nodeValue("Shape path", self, JUNCTION_CONNECT.input, VALUE_TYPE.pathnode, noone)
|
|
|
|
.setVisible(true, true);
|
|
|
|
|
|
|
|
outputs[| 0] = nodeValue("Surface out", self, JUNCTION_CONNECT.output, VALUE_TYPE.surface, noone);
|
2022-01-13 05:24:03 +01:00
|
|
|
|
|
|
|
input_display_list = [
|
2023-05-03 21:42:17 +02:00
|
|
|
["Output", false], 0, 6,
|
2023-02-14 05:32:32 +01:00
|
|
|
["Shape", false], 2, 14, 3, 9, 4, 13, 5, 7, 8,
|
|
|
|
["Render", true], 10, 1, 11, 12
|
2022-01-13 05:24:03 +01:00
|
|
|
];
|
|
|
|
|
2023-10-23 11:39:41 +02:00
|
|
|
temp_surface = [ noone ];
|
|
|
|
|
2023-03-19 09:17:39 +01:00
|
|
|
attribute_surface_depth();
|
|
|
|
|
2023-10-23 11:39:41 +02:00
|
|
|
static drawOverlay = function(active, _x, _y, _s, _mx, _my, _snx, _sny) { #region
|
2023-10-02 08:57:44 +02:00
|
|
|
var _path = getInputData(14);
|
2023-02-14 05:32:32 +01:00
|
|
|
if(_path != noone && struct_has(_path, "getPointRatio")) return;
|
2022-12-19 13:35:30 +01:00
|
|
|
inputs[| 3].drawOverlay(active, _x, _y, _s, _mx, _my, _snx, _sny);
|
2023-10-23 11:39:41 +02:00
|
|
|
} #endregion
|
2022-01-13 05:24:03 +01:00
|
|
|
|
2023-10-23 11:39:41 +02:00
|
|
|
static processData = function(_outSurf, _data, _output_index, _array_index) { #region
|
2022-01-13 05:24:03 +01:00
|
|
|
var _dim = _data[0];
|
|
|
|
var _bg = _data[1];
|
|
|
|
var _shape = _data[2];
|
|
|
|
var _posit = _data[3];
|
|
|
|
var _aa = _data[6];
|
|
|
|
var _corner = _data[9];
|
2022-08-30 07:36:37 +02:00
|
|
|
var _color = _data[10];
|
2022-12-12 09:08:03 +01:00
|
|
|
var _df = _data[12];
|
2023-02-14 05:32:32 +01:00
|
|
|
var _path = _data[14];
|
2023-10-23 11:39:41 +02:00
|
|
|
var _bgC = _data[11];
|
2022-08-30 07:36:37 +02:00
|
|
|
var _bgcol = _bg? colToVec4(_data[11]) : [0, 0, 0, 0];
|
|
|
|
|
2023-02-14 05:32:32 +01:00
|
|
|
inputs[| 3].setVisible(true);
|
|
|
|
inputs[| 4].setVisible(true);
|
|
|
|
inputs[| 5].setVisible(true);
|
2023-03-13 10:45:56 +01:00
|
|
|
inputs[| 6].setVisible(_path == noone);
|
2023-02-14 05:32:32 +01:00
|
|
|
inputs[| 7].setVisible(true);
|
|
|
|
inputs[| 8].setVisible(true);
|
2023-03-13 10:45:56 +01:00
|
|
|
inputs[| 9].setVisible(true);
|
|
|
|
inputs[| 11].setVisible(_bg);
|
|
|
|
inputs[| 13].setVisible(true);
|
2022-01-13 05:24:03 +01:00
|
|
|
|
2023-03-19 09:17:39 +01:00
|
|
|
_outSurf = surface_verify(_outSurf, _dim[0], _dim[1], attrDepth());
|
2022-01-13 05:24:03 +01:00
|
|
|
|
2023-10-23 11:39:41 +02:00
|
|
|
if(_path != noone && struct_has(_path, "getPointRatio")) { #region
|
2023-02-14 05:32:32 +01:00
|
|
|
inputs[| 3].setVisible(false);
|
|
|
|
inputs[| 4].setVisible(false);
|
|
|
|
inputs[| 5].setVisible(false);
|
|
|
|
inputs[| 7].setVisible(false);
|
|
|
|
inputs[| 8].setVisible(false);
|
2023-03-13 10:45:56 +01:00
|
|
|
inputs[| 9].setVisible(false);
|
|
|
|
inputs[| 13].setVisible(false);
|
2023-02-14 05:32:32 +01:00
|
|
|
|
|
|
|
surface_set_target(_outSurf);
|
|
|
|
if(_bg) draw_clear_alpha(0, 1);
|
2023-03-19 09:17:39 +01:00
|
|
|
else DRAW_CLEAR
|
2023-02-14 05:32:32 +01:00
|
|
|
|
|
|
|
var points = [];
|
|
|
|
var segCount = _path.getSegmentCount();
|
2023-07-15 20:01:29 +02:00
|
|
|
if(segCount) {
|
2023-02-14 05:32:32 +01:00
|
|
|
var quality = 8;
|
|
|
|
var sample = quality * segCount;
|
|
|
|
|
|
|
|
for( var i = 0; i < sample; i++ ) {
|
|
|
|
var t = i / sample;
|
|
|
|
var pos = _path.getPointRatio(t);
|
|
|
|
|
|
|
|
array_push(points, pos);
|
|
|
|
}
|
|
|
|
|
|
|
|
var triangles = polygon_triangulate(points);
|
|
|
|
|
|
|
|
draw_set_color(_color);
|
|
|
|
draw_primitive_begin(pr_trianglelist);
|
2023-07-25 20:12:40 +02:00
|
|
|
for( var i = 0, n = array_length(triangles); i < n; i++ ) {
|
2023-02-14 05:32:32 +01:00
|
|
|
var tri = triangles[i];
|
2023-03-19 09:17:39 +01:00
|
|
|
var p0 = tri[0];
|
|
|
|
var p1 = tri[1];
|
|
|
|
var p2 = tri[2];
|
2023-02-14 05:32:32 +01:00
|
|
|
|
2023-03-19 09:17:39 +01:00
|
|
|
draw_vertex(p0.x, p0.y);
|
|
|
|
draw_vertex(p1.x, p1.y);
|
|
|
|
draw_vertex(p2.x, p2.y);
|
2023-02-14 05:32:32 +01:00
|
|
|
}
|
|
|
|
draw_primitive_end();
|
|
|
|
}
|
|
|
|
surface_reset_target();
|
|
|
|
|
|
|
|
return _outSurf;
|
2023-10-23 11:39:41 +02:00
|
|
|
} #endregion
|
2023-02-14 05:32:32 +01:00
|
|
|
|
2023-10-23 11:39:41 +02:00
|
|
|
surface_set_shader(_outSurf, sh_shape);
|
2022-01-13 05:24:03 +01:00
|
|
|
if(_bg) draw_clear_alpha(0, 1);
|
2023-03-19 09:17:39 +01:00
|
|
|
else DRAW_CLEAR
|
2022-01-13 05:24:03 +01:00
|
|
|
|
2023-10-23 11:39:41 +02:00
|
|
|
inputs[| 4].setVisible(false);
|
|
|
|
inputs[| 5].setVisible(false);
|
|
|
|
inputs[| 7].setVisible(false);
|
|
|
|
inputs[| 8].setVisible(false);
|
|
|
|
inputs[| 9].setVisible(false);
|
2023-01-17 08:11:55 +01:00
|
|
|
inputs[| 13].setVisible(false);
|
2023-10-23 11:39:41 +02:00
|
|
|
|
|
|
|
switch(_shape) { #region
|
2023-01-17 08:11:55 +01:00
|
|
|
case NODE_SHAPE_TYPE.rectangle :
|
|
|
|
inputs[| 9].setVisible(true);
|
|
|
|
break;
|
2022-01-13 05:24:03 +01:00
|
|
|
case NODE_SHAPE_TYPE.elipse :
|
|
|
|
break;
|
|
|
|
case NODE_SHAPE_TYPE.regular :
|
2022-01-19 06:11:17 +01:00
|
|
|
inputs[| 4].setVisible(true);
|
|
|
|
inputs[| 7].setVisible(true);
|
|
|
|
inputs[| 9].setVisible(true);
|
2022-01-13 05:24:03 +01:00
|
|
|
|
2023-10-23 11:39:41 +02:00
|
|
|
shader_set_i("sides", _data[4]);
|
|
|
|
shader_set_f("angle", degtorad(_data[7]));
|
2022-01-13 05:24:03 +01:00
|
|
|
break;
|
|
|
|
case NODE_SHAPE_TYPE.star :
|
2022-01-19 06:11:17 +01:00
|
|
|
inputs[| 4].setVisible(true);
|
|
|
|
inputs[| 5].setVisible(true);
|
|
|
|
inputs[| 7].setVisible(true);
|
|
|
|
inputs[| 9].setVisible(true);
|
2023-10-23 11:39:41 +02:00
|
|
|
|
2023-01-17 08:11:55 +01:00
|
|
|
inputs[| 5].name = "Inner radius";
|
2023-10-23 11:39:41 +02:00
|
|
|
|
|
|
|
shader_set_i("sides", _data[4]);
|
|
|
|
shader_set_f("angle", degtorad(_data[7]));
|
|
|
|
shader_set_f("inner", _data[5]);
|
2022-01-13 05:24:03 +01:00
|
|
|
break;
|
|
|
|
case NODE_SHAPE_TYPE.arc :
|
2022-01-19 06:11:17 +01:00
|
|
|
inputs[| 5].setVisible(true);
|
|
|
|
inputs[| 8].setVisible(true);
|
2023-01-17 08:11:55 +01:00
|
|
|
|
|
|
|
inputs[| 5].name = "Inner radius";
|
2022-01-13 05:24:03 +01:00
|
|
|
|
|
|
|
var ar = _data[8];
|
|
|
|
var center = degtorad(ar[0] + ar[1]) / 2;
|
|
|
|
var range = degtorad(ar[0] - ar[1]) / 2;
|
2023-10-23 11:39:41 +02:00
|
|
|
shader_set_f("angle", center);
|
|
|
|
shader_set_f("angle_range", [ sin(range), cos(range) ] );
|
|
|
|
shader_set_f("inner", _data[5] / 2);
|
2022-01-13 05:24:03 +01:00
|
|
|
break;
|
2023-01-17 08:11:55 +01:00
|
|
|
case NODE_SHAPE_TYPE.teardrop :
|
2023-10-23 11:39:41 +02:00
|
|
|
inputs[| 5].setVisible(true);
|
2023-01-17 08:11:55 +01:00
|
|
|
inputs[| 13].setVisible(true);
|
|
|
|
|
2023-10-23 11:39:41 +02:00
|
|
|
inputs[| 5].name = "End radius";
|
2023-01-17 08:11:55 +01:00
|
|
|
inputs[| 13].name = "Start radius";
|
|
|
|
|
2023-10-23 11:39:41 +02:00
|
|
|
shader_set_f("edRad", _data[ 5]);
|
|
|
|
shader_set_f("stRad", _data[13]);
|
2023-01-17 08:11:55 +01:00
|
|
|
break;
|
|
|
|
case NODE_SHAPE_TYPE.cross :
|
2023-10-23 11:39:41 +02:00
|
|
|
inputs[| 9].setVisible(true);
|
2023-01-17 08:11:55 +01:00
|
|
|
inputs[| 13].setVisible(true);
|
2023-10-23 11:39:41 +02:00
|
|
|
|
2023-01-17 08:11:55 +01:00
|
|
|
inputs[| 13].name = "Outer radius";
|
|
|
|
|
2023-10-23 11:39:41 +02:00
|
|
|
shader_set_f("outer", _data[13]);
|
2023-01-17 08:11:55 +01:00
|
|
|
break;
|
|
|
|
case NODE_SHAPE_TYPE.leaf :
|
|
|
|
inputs[| 5].setVisible(true);
|
|
|
|
inputs[| 13].setVisible(true);
|
2023-10-23 11:39:41 +02:00
|
|
|
|
2023-01-17 08:11:55 +01:00
|
|
|
inputs[| 5].name = "Inner radius";
|
|
|
|
inputs[| 13].name = "Outer radius";
|
|
|
|
|
2023-10-23 11:39:41 +02:00
|
|
|
shader_set_f("inner", _data[ 5]);
|
|
|
|
shader_set_f("outer", _data[13]);
|
2022-01-13 05:24:03 +01:00
|
|
|
break;
|
2023-10-23 11:39:41 +02:00
|
|
|
} #endregion
|
2022-01-13 05:24:03 +01:00
|
|
|
|
2023-10-23 11:39:41 +02:00
|
|
|
shader_set_f("dimension", _dim);
|
|
|
|
shader_set_i("shape", _shape);
|
|
|
|
shader_set_f("bgColor", _bgcol);
|
|
|
|
shader_set_i("aa", _aa);
|
|
|
|
shader_set_i("drawDF", _df);
|
|
|
|
shader_set_f("corner", _corner);
|
|
|
|
|
|
|
|
shader_set_f("center", [ _posit[0] / _dim[0], _posit[1] / _dim[1] ]);
|
|
|
|
shader_set_f("scale", [ _posit[2] / _dim[0], _posit[3] / _dim[1] ]);
|
2022-08-30 07:36:37 +02:00
|
|
|
|
2023-10-23 11:39:41 +02:00
|
|
|
draw_sprite_stretched_ext(s_fx_pixel, 0, 0, 0, _dim[0], _dim[1], _color, 1);
|
|
|
|
surface_reset_shader();
|
2022-12-27 04:00:50 +01:00
|
|
|
|
|
|
|
return _outSurf;
|
2023-10-23 11:39:41 +02:00
|
|
|
} #endregion
|
2022-01-13 05:24:03 +01:00
|
|
|
}
|