2024-08-25 10:18:22 +02:00
|
|
|
global.node_shape_keys = [
|
2024-10-09 09:22:48 +02:00
|
|
|
"rectangle", "square", "diamond", "trapezoid", "parallelogram", "half",
|
2024-10-07 07:50:21 +02:00
|
|
|
"circle", "ellipse", "arc", "donut", "crescent", "ring", "squircle",
|
|
|
|
"regular polygon", "triangle", "pentagon", "hexagon", "star", "cross",
|
2024-10-09 09:22:48 +02:00
|
|
|
"line", "arrow",
|
|
|
|
"teardrop", "leaf", "heart", "gear",
|
2024-08-25 10:18:22 +02:00
|
|
|
];
|
|
|
|
|
|
|
|
function Node_create_Shape(_x, _y, _group = noone, _param = {}) {
|
|
|
|
var query = struct_try_get(_param, "query", "");
|
|
|
|
var node = new Node_Shape(_x, _y, _group).skipDefault();
|
|
|
|
var ind = -1;
|
2024-02-16 07:44:36 +01:00
|
|
|
|
2024-08-25 10:18:22 +02:00
|
|
|
switch(query) {
|
|
|
|
case "square" : ind = array_find_string(node.shape_types, "rectangle"); break;
|
|
|
|
case "circle" : ind = array_find_string(node.shape_types, "ellipse"); break;
|
|
|
|
case "ring" : ind = array_find_string(node.shape_types, "donut"); break;
|
|
|
|
case "triangle" : ind = array_find_string(node.shape_types, "regular polygon"); node.inputs[4].setValue(3); break;
|
|
|
|
case "pentagon" : ind = array_find_string(node.shape_types, "regular polygon"); node.inputs[4].setValue(5); break;
|
|
|
|
case "hexagon" : ind = array_find_string(node.shape_types, "regular polygon"); node.inputs[4].setValue(6); break;
|
|
|
|
|
|
|
|
default : ind = array_find_string(node.shape_types, query);
|
2024-02-16 07:44:36 +01:00
|
|
|
}
|
|
|
|
|
2024-08-25 10:18:22 +02:00
|
|
|
if(ind >= 0) node.inputs[2].setValue(ind);
|
|
|
|
|
|
|
|
return node;
|
|
|
|
}
|
2024-02-16 07:44:36 +01:00
|
|
|
|
2023-02-28 09:43:01 +01:00
|
|
|
function Node_Shape(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) constructor {
|
2024-06-20 08:55:04 +02:00
|
|
|
name = "Draw Shape";
|
2022-01-13 05:24:03 +01:00
|
|
|
|
2024-03-26 04:03:45 +01:00
|
|
|
onSurfaceSize = function() { return getInputData(0, DEF_SURF); };
|
|
|
|
|
2024-08-18 06:16:20 +02:00
|
|
|
newInput(0, nodeValue_Dimension(self));
|
2022-01-13 05:24:03 +01:00
|
|
|
|
2024-08-18 06:16:20 +02:00
|
|
|
newInput(1, nodeValue_Bool("Background", self, false));
|
2022-01-13 05:24:03 +01:00
|
|
|
|
2024-07-15 11:44:07 +02:00
|
|
|
shape_types = [
|
2024-10-09 09:22:48 +02:00
|
|
|
"Rectangle", "Diamond", "Trapezoid", "Parallelogram", "Half",
|
2024-10-09 03:56:39 +02:00
|
|
|
-1, "Ellipse", "Arc", "Donut", "Crescent", "Disk Segment", "Pie", "Squircle",
|
|
|
|
-1, "Regular polygon", "Star", "Cross", "Rounded Cross",
|
2024-10-09 06:38:35 +02:00
|
|
|
-1, "Line", "Arrow",
|
|
|
|
-1, "Teardrop", "Leaf", "Heart", "Gear",
|
2024-07-15 11:44:07 +02:00
|
|
|
];
|
2024-05-25 04:51:52 +02:00
|
|
|
shape_types_str = [];
|
|
|
|
|
2024-05-25 07:01:54 +02:00
|
|
|
var _ind = 0;
|
2024-07-15 11:44:07 +02:00
|
|
|
for( var i = 0, n = array_length(shape_types); i < n; i++ )
|
|
|
|
shape_types_str[i] = shape_types[i] == -1? -1 : new scrollItem(shape_types[i], s_node_shape_type, _ind++);
|
2024-01-28 09:53:41 +01:00
|
|
|
|
2024-08-18 06:16:20 +02:00
|
|
|
newInput(2, nodeValue_Enum_Scroll("Shape", self, 0, { data: shape_types_str, horizontal: true, text_pad: ui(16) }));
|
2022-01-13 05:24:03 +01:00
|
|
|
|
2024-10-09 06:38:35 +02:00
|
|
|
inputs[2].options_histories = [ shape_types, { cond: function() /*=>*/ {return LOADING_VERSION < 1_18_00_0}, list: global.node_shape_keys_18 } ];
|
|
|
|
|
2024-08-18 09:13:41 +02:00
|
|
|
newInput(3, nodeValue_Area("Position", self, DEF_AREA_REF, { onSurfaceSize, useShape : false }))
|
2024-08-07 13:20:45 +02:00
|
|
|
.setUnitRef(onSurfaceSize, VALUE_UNIT.reference);
|
2022-01-13 05:24:03 +01:00
|
|
|
|
2024-08-18 09:13:41 +02:00
|
|
|
newInput(4, nodeValue_Int("Sides", self, 3))
|
2022-01-19 03:05:13 +01:00
|
|
|
.setVisible(false);
|
2022-01-13 05:24:03 +01:00
|
|
|
|
2024-08-18 09:13:41 +02:00
|
|
|
newInput(5, nodeValue_Float("Inner radius", self, 0.5))
|
2023-10-02 08:57:44 +02:00
|
|
|
.setDisplay(VALUE_DISPLAY.slider)
|
2022-01-13 05:24:03 +01:00
|
|
|
.setVisible(false);
|
|
|
|
|
2024-08-18 06:16:20 +02:00
|
|
|
newInput(6, nodeValue_Bool("Anti-aliasing", self, false));
|
2022-01-19 03:05:13 +01:00
|
|
|
|
2024-08-18 06:16:20 +02:00
|
|
|
newInput(7, nodeValue_Rotation("Rotation", self, 0));
|
2022-01-13 05:24:03 +01:00
|
|
|
|
2024-08-18 06:16:20 +02:00
|
|
|
newInput(8, nodeValue_Rotation_Range("Angle range", self, [ 0, 180 ]));
|
2022-01-13 05:24:03 +01:00
|
|
|
|
2024-08-18 09:13:41 +02:00
|
|
|
newInput(9, nodeValue_Float("Corner radius", self, 0))
|
2024-07-07 12:55:27 +02:00
|
|
|
.setValidator(VV_clamp(0, .5))
|
2024-05-01 14:28:15 +02:00
|
|
|
.setDisplay(VALUE_DISPLAY.slider, { range: [0, 0.5, 0.001] });
|
2024-08-08 06:57:51 +02:00
|
|
|
inputs[9].overlay_draw_text = false;
|
2022-01-13 05:24:03 +01:00
|
|
|
|
2024-08-18 06:16:20 +02:00
|
|
|
newInput(10, nodeValue_Color("Shape color", self, c_white));
|
2022-08-30 07:36:37 +02:00
|
|
|
|
2024-08-18 06:16:20 +02:00
|
|
|
newInput(11, nodeValue_Color("Background color", self, c_black));
|
2022-01-13 05:24:03 +01:00
|
|
|
|
2024-08-18 06:16:20 +02:00
|
|
|
newInput(12, nodeValue_Bool("Height", self, false));
|
2022-12-12 09:08:03 +01:00
|
|
|
|
2024-08-18 09:13:41 +02:00
|
|
|
newInput(13, nodeValue_Float("Start radius", self, 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
|
|
|
|
2024-08-18 09:13:41 +02:00
|
|
|
newInput(14, nodeValue_PathNode("Shape path", self, noone))
|
2023-02-14 05:32:32 +01:00
|
|
|
.setVisible(true, true);
|
|
|
|
|
2024-09-14 07:37:19 +02:00
|
|
|
newInput(15, nodeValue_Enum_Scroll("Positioning Mode", self, 2, [ "Area", "Center + Scale", "Full Image" ]))
|
2024-01-07 12:18:20 +01:00
|
|
|
|
2024-08-18 09:13:41 +02:00
|
|
|
newInput(16, nodeValue_Vec2("Center", self, [ DEF_SURF_W / 2, DEF_SURF_H / 2 ] ))
|
2024-03-26 04:03:45 +01:00
|
|
|
.setUnitRef(onSurfaceSize);
|
2024-01-07 12:18:20 +01:00
|
|
|
|
2024-08-18 09:13:41 +02:00
|
|
|
newInput(17, nodeValue_Vec2("Half Size", self, [ DEF_SURF_W / 2, DEF_SURF_H / 2 ] ))
|
2024-03-26 04:03:45 +01:00
|
|
|
.setUnitRef(onSurfaceSize);
|
2024-01-07 12:18:20 +01:00
|
|
|
|
2024-08-18 06:16:20 +02:00
|
|
|
newInput(18, nodeValue_Bool("Tile", self, false));
|
2024-01-07 12:18:20 +01:00
|
|
|
|
2024-08-18 06:16:20 +02:00
|
|
|
newInput(19, nodeValue_Rotation("Shape rotation", self, 0));
|
2024-01-22 14:23:35 +01:00
|
|
|
|
2024-08-18 06:16:20 +02:00
|
|
|
newInput(20, nodeValue_Slider_Range("Level", self, [ 0, 1 ]));
|
2024-02-15 14:23:26 +01:00
|
|
|
|
2024-08-18 06:16:20 +02:00
|
|
|
newInput(21, nodeValue_Slider_Range("Angles", self, [ 0.5, 1.0 ]));
|
2024-05-25 04:51:52 +02:00
|
|
|
|
2024-08-18 09:13:41 +02:00
|
|
|
newInput(22, nodeValue_Float("Skew", self, 0.5 ))
|
2024-05-25 04:51:52 +02:00
|
|
|
.setDisplay(VALUE_DISPLAY.slider);
|
|
|
|
|
2024-10-09 06:38:35 +02:00
|
|
|
newInput(23, nodeValue_Float("Arrow Sizes", self, 0.3 ));
|
|
|
|
|
|
|
|
newInput(24, nodeValue_Float("Arrow Head", self, 1 ));
|
2024-05-25 07:01:54 +02:00
|
|
|
|
2024-08-18 06:16:20 +02:00
|
|
|
newInput(25, nodeValue_Int("Teeth Amount", self, 6 ));
|
2024-06-20 08:55:04 +02:00
|
|
|
|
2024-08-18 06:16:20 +02:00
|
|
|
newInput(26, nodeValue_Vec2("Teeth Size", self, [ 0.2, 0.2 ] , { slideSpeed : 0.01 }));
|
2024-06-20 08:55:04 +02:00
|
|
|
|
2024-08-18 06:16:20 +02:00
|
|
|
newInput(27, nodeValue_Rotation("Teeth Rotation", self, 0));
|
2024-08-25 10:18:22 +02:00
|
|
|
|
|
|
|
newInput(28, nodeValue_Float("Shape Scale", self, 1))
|
|
|
|
.setDisplay(VALUE_DISPLAY.slider);
|
|
|
|
|
[Blend, Composite] Add blends modes: color burn. linear burn, color dodge, linear dodge, soft light, hard light, vivid light, linear light, pin light, exclusion, divide.
2024-10-05 09:27:38 +02:00
|
|
|
newInput(29, nodeValue_Curve("Curve", self, CURVE_DEF_01));
|
2024-08-25 10:18:22 +02:00
|
|
|
|
2024-09-14 07:37:19 +02:00
|
|
|
newInput(30, nodeValue_Bool("Caps", self, false));
|
|
|
|
|
|
|
|
newInput(31, nodeValue_Float("Factor", self, 2.5));
|
|
|
|
|
2024-10-09 06:38:35 +02:00
|
|
|
newInput(32, nodeValue_Vec2("Point 1", self, [ 0, 0 ]))
|
|
|
|
.setUnitRef(onSurfaceSize, VALUE_UNIT.reference);
|
|
|
|
|
|
|
|
newInput(33, nodeValue_Vec2("Point 2", self, [ 1, 1 ]))
|
|
|
|
.setUnitRef(onSurfaceSize, VALUE_UNIT.reference);
|
|
|
|
|
|
|
|
newInput(34, nodeValue_Float("Thickness", self, 0.1))
|
|
|
|
.setDisplay(VALUE_DISPLAY.slider);
|
|
|
|
|
|
|
|
newInput(35, nodeValue_Vec2("Point 3", self, [ 1, 0 ]))
|
|
|
|
.setUnitRef(onSurfaceSize, VALUE_UNIT.reference);
|
|
|
|
|
2024-09-04 03:57:11 +02:00
|
|
|
newOutput(0, nodeValue_Output("Surface out", self, VALUE_TYPE.surface, noone));
|
2022-01-13 05:24:03 +01:00
|
|
|
|
|
|
|
input_display_list = [
|
2024-01-07 12:18:20 +01:00
|
|
|
["Output", false], 0, 6,
|
2024-08-25 10:18:22 +02:00
|
|
|
["Transform", false], 15, 3, 16, 17, 19, 28,
|
2024-10-09 06:38:35 +02:00
|
|
|
["Shape", false], 14, 2, 32, 33, 35, 34, /**/ 9, 4, 13, 5, 7, 8, 21, 22, 23, 24, 25, 26, 27, 30, 31,
|
2024-08-26 06:54:36 +02:00
|
|
|
["Render", true], 10, 18,
|
|
|
|
["Height", true, 12], 29, 20,
|
2024-01-08 08:10:50 +01:00
|
|
|
["Background", true, 1], 11,
|
2022-01-13 05:24:03 +01:00
|
|
|
];
|
|
|
|
|
2023-10-23 11:39:41 +02:00
|
|
|
temp_surface = [ noone ];
|
2024-05-05 10:29:43 +02:00
|
|
|
use_path = false;
|
|
|
|
path_points = [];
|
|
|
|
point_simp = [];
|
|
|
|
triangles = [];
|
2023-10-23 11:39:41 +02:00
|
|
|
|
2023-03-19 09:17:39 +01:00
|
|
|
attribute_surface_depth();
|
|
|
|
|
2024-07-07 06:07:42 +02:00
|
|
|
static drawOverlay = function(hover, active, _x, _y, _s, _mx, _my, _snx, _sny) {
|
2024-05-10 04:01:14 +02:00
|
|
|
PROCESSOR_OVERLAY_CHECK
|
|
|
|
|
2024-07-02 12:18:32 +02:00
|
|
|
var _hov = false;
|
|
|
|
|
2024-05-05 10:29:43 +02:00
|
|
|
if(use_path) {
|
|
|
|
draw_set_text(f_p3, fa_center, fa_top);
|
|
|
|
draw_set_color(COLORS._main_accent);
|
|
|
|
var ox, oy, nx, ny;
|
|
|
|
|
|
|
|
for (var i = 0, n = array_length(point_simp); i < n; i++) {
|
|
|
|
var p = point_simp[i];
|
|
|
|
nx = _x + p.x * _s;
|
|
|
|
ny = _y + p.y * _s;
|
|
|
|
|
|
|
|
if(i) draw_line(ox, oy, nx, ny);
|
|
|
|
|
|
|
|
ox = nx;
|
|
|
|
oy = ny;
|
|
|
|
}
|
2024-07-02 12:18:32 +02:00
|
|
|
return _hov;
|
2024-05-05 10:29:43 +02:00
|
|
|
}
|
2024-01-07 12:18:20 +01:00
|
|
|
|
2024-10-09 06:38:35 +02:00
|
|
|
var _shape = current_data[ 2];
|
|
|
|
var _posMode = current_data[15];
|
2024-07-07 06:07:42 +02:00
|
|
|
var _pos = [ 0, 0 ];
|
|
|
|
var _sca = [ 1, 1 ];
|
|
|
|
var _px, _py;
|
|
|
|
var hv;
|
|
|
|
|
|
|
|
var _hov = false;
|
|
|
|
var _int = hover;
|
|
|
|
|
2024-10-09 06:38:35 +02:00
|
|
|
var _shp = array_safe_get(shape_types, _shape, "");
|
|
|
|
if(is_struct(_shp)) _shp = _shp.data;
|
|
|
|
|
|
|
|
switch(_shp) {
|
|
|
|
case "Arrow" :
|
|
|
|
case "Line" :
|
|
|
|
hv = inputs[32].drawOverlay(_int, active, _x, _y, _s, _mx, _my, _snx, _sny); _hov |= hv; _int &= !_hov;
|
|
|
|
hv = inputs[33].drawOverlay(_int, active, _x, _y, _s, _mx, _my, _snx, _sny); _hov |= hv; _int &= !_hov;
|
|
|
|
return _hov;
|
2024-10-09 09:22:48 +02:00
|
|
|
|
|
|
|
case "Half" :
|
|
|
|
hv = inputs[32].drawOverlay(_int, active, _x, _y, _s, _mx, _my, _snx, _sny); _hov |= hv; _int &= !_hov;
|
|
|
|
return _hov;
|
2024-10-09 06:38:35 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if(_posMode == 0) {
|
2024-07-07 06:07:42 +02:00
|
|
|
_pos = [ current_data[3][0], current_data[3][1] ];
|
|
|
|
_sca = [ current_data[3][2], current_data[3][3] ];
|
|
|
|
|
2024-10-09 06:38:35 +02:00
|
|
|
} else if(_posMode == 1) {
|
2024-07-07 06:07:42 +02:00
|
|
|
_pos = current_data[16];
|
|
|
|
_sca = current_data[17];
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2024-10-09 06:38:35 +02:00
|
|
|
if(inputs[9].show_in_inspector && _posMode != 2) { // corner
|
|
|
|
var _px = _x + _pos[0] * _s;
|
|
|
|
var _py = _y + _pos[1] * _s;
|
|
|
|
|
|
|
|
var _x0 = _px - _sca[0] * _s;
|
|
|
|
var _y0 = _py - _sca[1] * _s;
|
|
|
|
var _x1 = _px + _sca[0] * _s;
|
|
|
|
var _y1 = _py + _sca[1] * _s;
|
|
|
|
|
|
|
|
var aa = -45;
|
|
|
|
var ar = 90;
|
|
|
|
|
|
|
|
if(_sca[0] < 0 && _sca[1] < 0) { aa = 135; ar = -90; }
|
|
|
|
else if(_sca[0] < 0 && _sca[1] > 0) { aa = -135; ar = 0; }
|
|
|
|
else if(_sca[0] > 0 && _sca[1] < 0) { aa = 45; ar = 180; }
|
|
|
|
|
|
|
|
var _max_s = max(abs(_sca[0]), abs(_sca[1]));
|
|
|
|
var _corr = current_data[9] * _s * _max_s;
|
|
|
|
var _cor = _corr / (sqrt(2) - 1);
|
|
|
|
|
|
|
|
var cx = _x0 + lengthdir_x(_cor, aa);
|
|
|
|
var cy = _y0 + lengthdir_y(_cor, aa);
|
|
|
|
|
|
|
|
draw_set_color(COLORS._main_accent);
|
|
|
|
draw_arc(cx, cy, _cor - _corr, ar, ar + 90, 2);
|
|
|
|
|
|
|
|
hv = inputs[9].drawOverlay(_int, active, _x0, _y0, _s, _mx, _my, _snx, _sny, aa, _max_s, 1); _hov |= hv; _int &= !_hov;
|
2024-07-07 06:07:42 +02:00
|
|
|
}
|
2024-01-07 12:18:20 +01:00
|
|
|
|
2024-10-09 06:38:35 +02:00
|
|
|
if(_posMode == 0) {
|
2024-08-08 06:57:51 +02:00
|
|
|
hv = inputs[3].drawOverlay(_int, active, _x, _y, _s, _mx, _my, _snx, _sny); _hov |= hv; _int &= !_hov;
|
2024-07-02 12:18:32 +02:00
|
|
|
|
2024-10-09 06:38:35 +02:00
|
|
|
} else if(_posMode == 1) {
|
2024-07-07 06:07:42 +02:00
|
|
|
_px = _x + _pos[0] * _s;
|
|
|
|
_py = _y + _pos[1] * _s;
|
2024-01-07 12:18:20 +01:00
|
|
|
|
2024-08-08 06:57:51 +02:00
|
|
|
hv = inputs[16].drawOverlay(_int, active, _x, _y, _s, _mx, _my, _snx, _sny); _hov |= hv; _int &= !_hov;
|
|
|
|
hv = inputs[17].drawOverlay(_int, active, _px, _py, _s, _mx, _my, _snx, _sny); _hov |= hv; _int &= !_hov;
|
2024-07-07 06:07:42 +02:00
|
|
|
|
2024-01-07 12:18:20 +01:00
|
|
|
}
|
2024-07-02 12:18:32 +02:00
|
|
|
|
|
|
|
return _hov;
|
2024-07-07 06:07:42 +02:00
|
|
|
}
|
2022-01-13 05:24:03 +01:00
|
|
|
|
2024-08-07 04:16:09 +02:00
|
|
|
static processData = function(_outSurf, _data, _output_index, _array_index) {
|
2022-01-13 05:24:03 +01:00
|
|
|
var _dim = _data[0];
|
|
|
|
var _bg = _data[1];
|
|
|
|
var _shape = _data[2];
|
|
|
|
var _aa = _data[6];
|
2024-07-07 06:07:42 +02:00
|
|
|
var _corner = _data[9]; _corner = clamp(_corner, 0, .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];
|
|
|
|
|
2024-01-07 12:18:20 +01:00
|
|
|
var _posTyp = _data[15];
|
|
|
|
var _tile = _data[18];
|
2024-01-22 14:23:35 +01:00
|
|
|
var _rotat = _data[19];
|
2024-02-15 14:23:26 +01:00
|
|
|
var _level = _data[20];
|
2024-08-26 06:54:36 +02:00
|
|
|
var _curve = _data[29];
|
2024-08-25 10:18:22 +02:00
|
|
|
var _shpSca = _data[28];
|
2024-01-07 12:18:20 +01:00
|
|
|
|
|
|
|
var _center = [ 0, 0 ];
|
|
|
|
var _scale = [ 0, 0 ];
|
|
|
|
|
|
|
|
switch(_posTyp) {
|
|
|
|
case 0 :
|
|
|
|
var _area = _data[3];
|
|
|
|
|
2024-07-07 04:17:44 +02:00
|
|
|
_center = [ _area[0] / _dim[0], _area[1] / _dim[1] ];
|
|
|
|
_scale = [ abs(_area[2] / _dim[0]), abs(_area[3] / _dim[1]) ];
|
2024-01-07 12:18:20 +01:00
|
|
|
break;
|
2024-08-25 10:18:22 +02:00
|
|
|
|
2024-01-07 12:18:20 +01:00
|
|
|
case 1 :
|
|
|
|
var _posit = _data[16];
|
|
|
|
var _scal = _data[17];
|
|
|
|
|
2024-07-07 04:17:44 +02:00
|
|
|
_center = [ _posit[0] / _dim[0], _posit[1] / _dim[1] ];
|
|
|
|
_scale = [ abs(_scal[0] / _dim[0]), abs(_scal[1] / _dim[1]) ];
|
2024-01-07 12:18:20 +01:00
|
|
|
break;
|
2024-08-25 10:18:22 +02:00
|
|
|
|
2024-01-07 12:18:20 +01:00
|
|
|
case 2 :
|
|
|
|
_center = [ 0.5, 0.5 ];
|
|
|
|
_scale = [ 0.5, 0.5 ];
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2024-08-25 10:18:22 +02:00
|
|
|
_scale[0] *= _shpSca;
|
|
|
|
_scale[1] *= _shpSca;
|
|
|
|
|
|
|
|
_level = [ _level[0] / _shpSca, _level[1] / _shpSca];
|
|
|
|
|
2024-08-08 06:57:51 +02:00
|
|
|
inputs[ 3].setVisible(_posTyp == 0);
|
|
|
|
inputs[16].setVisible(_posTyp == 1);
|
|
|
|
inputs[17].setVisible(_posTyp == 1);
|
|
|
|
|
|
|
|
inputs[ 6].setVisible(_path == noone);
|
|
|
|
inputs[12].setVisible(_path == noone);
|
|
|
|
inputs[20].setVisible(_path == noone);
|
|
|
|
inputs[15].setVisible(true);
|
2024-10-09 06:38:35 +02:00
|
|
|
|
2024-09-14 07:37:19 +02:00
|
|
|
inputs[30].setVisible(false);
|
|
|
|
inputs[31].setVisible(false);
|
2024-10-09 06:38:35 +02:00
|
|
|
inputs[32].setVisible(false);
|
|
|
|
inputs[33].setVisible(false);
|
|
|
|
inputs[34].setVisible(false);
|
|
|
|
inputs[35].setVisible(false);
|
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());
|
2024-05-05 10:29:43 +02:00
|
|
|
use_path = _path != noone && struct_has(_path, "getPointRatio");
|
2022-01-13 05:24:03 +01:00
|
|
|
|
2024-07-07 06:07:42 +02:00
|
|
|
if(use_path) {
|
2024-08-08 06:57:51 +02:00
|
|
|
inputs[ 3].setVisible(false);
|
|
|
|
inputs[ 4].setVisible(false);
|
|
|
|
inputs[ 5].setVisible(false);
|
|
|
|
inputs[ 7].setVisible(false);
|
|
|
|
inputs[ 8].setVisible(false);
|
|
|
|
inputs[ 9].setVisible(false);
|
|
|
|
inputs[13].setVisible(false);
|
|
|
|
inputs[15].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 segCount = _path.getSegmentCount();
|
2023-07-15 20:01:29 +02:00
|
|
|
if(segCount) {
|
2023-02-14 05:32:32 +01:00
|
|
|
var quality = 8;
|
2024-05-05 10:29:43 +02:00
|
|
|
var sample = quality * segCount;
|
|
|
|
var _step = 1 / sample;
|
2023-02-14 05:32:32 +01:00
|
|
|
|
2024-05-05 10:29:43 +02:00
|
|
|
path_points = array_verify(path_points, sample);
|
|
|
|
for( var i = 0; i < sample; i++ )
|
|
|
|
path_points[i] = _path.getPointRatio(i * _step, array_safe_get(path_points, i, undefined));
|
2023-02-14 05:32:32 +01:00
|
|
|
|
2024-05-05 10:29:43 +02:00
|
|
|
var tri = polygon_triangulate(path_points);
|
|
|
|
triangles = tri[0];
|
|
|
|
point_simp = tri[1];
|
2023-02-14 05:32:32 +01:00
|
|
|
|
|
|
|
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;
|
2024-07-07 06:07:42 +02:00
|
|
|
}
|
2023-02-14 05:32:32 +01:00
|
|
|
|
2023-10-23 11:39:41 +02:00
|
|
|
surface_set_shader(_outSurf, sh_shape);
|
2024-08-25 10:18:22 +02:00
|
|
|
if(_bg) {
|
|
|
|
draw_clear_alpha(0, 1);
|
|
|
|
} else {
|
|
|
|
DRAW_CLEAR
|
|
|
|
BLEND_OVERRIDE
|
|
|
|
}
|
2022-01-13 05:24:03 +01:00
|
|
|
|
2024-08-08 06:57:51 +02:00
|
|
|
inputs[ 4].setVisible(false);
|
|
|
|
inputs[ 5].setVisible(false);
|
|
|
|
inputs[ 7].setVisible(false);
|
|
|
|
inputs[ 8].setVisible(false);
|
|
|
|
inputs[ 9].setVisible(false);
|
|
|
|
inputs[13].setVisible(false);
|
|
|
|
inputs[18].setVisible( true);
|
|
|
|
inputs[21].setVisible(false);
|
|
|
|
inputs[22].setVisible(false);
|
|
|
|
inputs[23].setVisible(false);
|
|
|
|
inputs[24].setVisible(false);
|
|
|
|
inputs[25].setVisible(false);
|
|
|
|
inputs[26].setVisible(false);
|
|
|
|
inputs[27].setVisible(false);
|
2024-05-25 04:51:52 +02:00
|
|
|
|
|
|
|
var _shp = array_safe_get(shape_types, _shape, "");
|
|
|
|
if(is_struct(_shp)) _shp = _shp.data;
|
2023-10-23 11:39:41 +02:00
|
|
|
|
2024-08-07 04:16:09 +02:00
|
|
|
switch(_shp) {
|
2024-05-25 04:51:52 +02:00
|
|
|
case "Rectangle" :
|
2024-08-08 06:57:51 +02:00
|
|
|
inputs[ 9].setVisible( true);
|
|
|
|
inputs[18].setVisible(false);
|
2024-05-25 04:51:52 +02:00
|
|
|
|
|
|
|
shader_set_i("shape", 0);
|
2023-01-17 08:11:55 +01:00
|
|
|
break;
|
2024-05-25 04:51:52 +02:00
|
|
|
|
|
|
|
case "Diamond" :
|
2024-08-08 06:57:51 +02:00
|
|
|
inputs[ 9].setVisible( true);
|
2024-05-25 04:51:52 +02:00
|
|
|
|
|
|
|
shader_set_i("shape", 10);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case "Trapezoid" :
|
2024-08-08 06:57:51 +02:00
|
|
|
inputs[ 9].setVisible( true);
|
|
|
|
inputs[21].setVisible( true);
|
2024-05-25 04:51:52 +02:00
|
|
|
|
|
|
|
shader_set_i("shape", 11);
|
2024-06-24 13:49:54 +02:00
|
|
|
shader_set_2("trep", _data[21]);
|
2022-01-13 05:24:03 +01:00
|
|
|
break;
|
2024-05-25 04:51:52 +02:00
|
|
|
|
|
|
|
case "Parallelogram" :
|
2024-08-08 06:57:51 +02:00
|
|
|
inputs[ 9].setVisible( true);
|
|
|
|
inputs[22].setVisible( true);
|
2024-05-25 04:51:52 +02:00
|
|
|
|
|
|
|
shader_set_i("shape", 12);
|
|
|
|
shader_set_f("parall", _data[22]);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case "Ellipse" :
|
|
|
|
shader_set_i("shape", 1);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case "Regular polygon" :
|
2024-08-08 06:57:51 +02:00
|
|
|
inputs[4].setVisible(true);
|
|
|
|
inputs[7].setVisible(true);
|
|
|
|
inputs[9].setVisible(true);
|
2022-01-13 05:24:03 +01:00
|
|
|
|
2024-05-25 04:51:52 +02:00
|
|
|
shader_set_i("shape", 2);
|
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;
|
2024-05-25 04:51:52 +02:00
|
|
|
|
|
|
|
case "Star" :
|
2024-08-08 06:57:51 +02: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
|
|
|
|
2024-08-08 06:57:51 +02:00
|
|
|
inputs[5].name = "Inner radius";
|
2023-10-23 11:39:41 +02:00
|
|
|
|
2024-05-25 04:51:52 +02:00
|
|
|
shader_set_i("shape", 3);
|
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;
|
2024-05-25 04:51:52 +02:00
|
|
|
|
|
|
|
case "Arc" :
|
2024-08-08 06:57:51 +02:00
|
|
|
inputs[5].setVisible(true);
|
|
|
|
inputs[8].setVisible(true);
|
2024-09-14 07:37:19 +02:00
|
|
|
inputs[30].setVisible(true);
|
2023-01-17 08:11:55 +01:00
|
|
|
|
2024-08-08 06:57:51 +02: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;
|
2024-09-14 07:37:19 +02:00
|
|
|
var range = abs(degtorad(ar[0] - ar[1]) / 2);
|
2024-05-25 04:51:52 +02:00
|
|
|
|
2024-09-14 07:37:19 +02:00
|
|
|
shader_set_i("shape", 4);
|
|
|
|
shader_set_i("endcap", _data[30]);
|
|
|
|
shader_set_f("angle", center);
|
2023-10-23 11:39:41 +02:00
|
|
|
shader_set_f("angle_range", [ sin(range), cos(range) ] );
|
2024-09-14 07:37:19 +02:00
|
|
|
shader_set_f("inner", _data[5] / 2);
|
2022-01-13 05:24:03 +01:00
|
|
|
break;
|
2024-05-25 04:51:52 +02:00
|
|
|
|
|
|
|
case "Teardrop" :
|
2024-08-08 06:57:51 +02:00
|
|
|
inputs[ 5].setVisible(true);
|
|
|
|
inputs[13].setVisible(true);
|
2023-01-17 08:11:55 +01:00
|
|
|
|
2024-08-08 06:57:51 +02:00
|
|
|
inputs[ 5].name = "End radius";
|
|
|
|
inputs[13].name = "Start radius";
|
2023-01-17 08:11:55 +01:00
|
|
|
|
2024-05-25 04:51:52 +02:00
|
|
|
shader_set_i("shape", 5);
|
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;
|
2024-05-25 04:51:52 +02:00
|
|
|
|
|
|
|
case "Cross" :
|
2024-08-08 06:57:51 +02:00
|
|
|
inputs[ 9].setVisible(true);
|
|
|
|
inputs[13].setVisible(true);
|
2023-10-23 11:39:41 +02:00
|
|
|
|
2024-08-08 06:57:51 +02:00
|
|
|
inputs[13].name = "Outer radius";
|
2023-01-17 08:11:55 +01:00
|
|
|
|
2024-05-25 04:51:52 +02:00
|
|
|
shader_set_i("shape", 6);
|
2023-10-23 11:39:41 +02:00
|
|
|
shader_set_f("outer", _data[13]);
|
2023-01-17 08:11:55 +01:00
|
|
|
break;
|
2024-05-25 04:51:52 +02:00
|
|
|
|
|
|
|
case "Leaf" :
|
2024-08-08 06:57:51 +02:00
|
|
|
inputs[ 5].setVisible(true);
|
|
|
|
inputs[13].setVisible(true);
|
2023-10-23 11:39:41 +02:00
|
|
|
|
2024-08-08 06:57:51 +02:00
|
|
|
inputs[ 5].name = "Inner radius";
|
|
|
|
inputs[13].name = "Outer radius";
|
2023-01-17 08:11:55 +01:00
|
|
|
|
2024-05-25 04:51:52 +02:00
|
|
|
shader_set_i("shape", 7);
|
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;
|
2024-05-25 04:51:52 +02:00
|
|
|
|
|
|
|
case "Crescent" :
|
2024-08-08 06:57:51 +02:00
|
|
|
inputs[ 5].setVisible(true);
|
|
|
|
inputs[ 7].setVisible(true);
|
|
|
|
inputs[13].setVisible(true);
|
2024-01-07 12:18:20 +01:00
|
|
|
|
2024-08-08 06:57:51 +02:00
|
|
|
inputs[ 5].name = "Shift";
|
|
|
|
inputs[13].name = "Inner circle";
|
2024-01-07 12:18:20 +01:00
|
|
|
|
2024-05-25 04:51:52 +02:00
|
|
|
shader_set_i("shape", 8);
|
2024-01-07 12:18:20 +01:00
|
|
|
shader_set_f("outer", _data[ 5]);
|
2024-01-19 14:39:26 +01:00
|
|
|
shader_set_f("angle", -degtorad(_data[7]));
|
|
|
|
shader_set_f("inner", _data[13]);
|
|
|
|
break;
|
2024-05-25 04:51:52 +02:00
|
|
|
|
|
|
|
case "Donut" :
|
2024-08-08 06:57:51 +02:00
|
|
|
inputs[13].setVisible(true);
|
2024-01-19 14:39:26 +01:00
|
|
|
|
2024-08-08 06:57:51 +02:00
|
|
|
inputs[13].name = "Inner circle";
|
2024-01-19 14:39:26 +01:00
|
|
|
|
2024-05-25 04:51:52 +02:00
|
|
|
shader_set_i("shape", 9);
|
2024-01-07 12:18:20 +01:00
|
|
|
shader_set_f("inner", _data[13]);
|
|
|
|
break;
|
2024-05-25 04:51:52 +02:00
|
|
|
|
2024-05-25 07:01:54 +02:00
|
|
|
case "Heart":
|
|
|
|
|
|
|
|
shader_set_i("shape", 13);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case "Disk Segment":
|
2024-08-08 06:57:51 +02:00
|
|
|
inputs[13].setVisible(true);
|
2024-05-25 07:01:54 +02:00
|
|
|
|
2024-08-08 06:57:51 +02:00
|
|
|
inputs[13].name = "Segment Size";
|
2024-05-25 07:01:54 +02:00
|
|
|
|
|
|
|
shader_set_i("shape", 14);
|
|
|
|
shader_set_f("inner", -1 + _data[13] * 2.);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case "Pie":
|
2024-08-08 06:57:51 +02:00
|
|
|
inputs[ 7].setVisible(true);
|
2024-05-25 07:01:54 +02:00
|
|
|
|
|
|
|
shader_set_i("shape", 15);
|
|
|
|
shader_set_f("angle", degtorad(_data[7]));
|
|
|
|
break;
|
|
|
|
|
|
|
|
case "Rounded Cross":
|
2024-08-08 06:57:51 +02:00
|
|
|
inputs[ 9].setVisible(true);
|
2024-05-25 07:01:54 +02:00
|
|
|
|
|
|
|
shader_set_i("shape", 16);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case "Arrow":
|
2024-08-08 06:57:51 +02:00
|
|
|
inputs[23].setVisible(true);
|
|
|
|
inputs[24].setVisible(true);
|
2024-10-09 06:38:35 +02:00
|
|
|
inputs[32].setVisible(true);
|
|
|
|
inputs[33].setVisible(true);
|
|
|
|
inputs[34].setVisible(true);
|
2024-05-25 07:01:54 +02:00
|
|
|
|
|
|
|
shader_set_i("shape", 17);
|
2024-10-09 06:38:35 +02:00
|
|
|
shader_set_f("arrow", _data[23] / _data[24]);
|
2024-05-25 07:01:54 +02:00
|
|
|
shader_set_f("arrow_head", _data[24]);
|
2024-10-09 06:38:35 +02:00
|
|
|
|
|
|
|
shader_set_2("point1", _data[32]);
|
|
|
|
shader_set_2("point2", _data[33]);
|
|
|
|
shader_set_f("thickness", _data[34]);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case "Line":
|
|
|
|
inputs[32].setVisible(true);
|
|
|
|
inputs[33].setVisible(true);
|
|
|
|
inputs[34].setVisible(true);
|
|
|
|
|
|
|
|
shader_set_i("shape", 20);
|
|
|
|
shader_set_2("point1", _data[32]);
|
|
|
|
shader_set_2("point2", _data[33]);
|
|
|
|
shader_set_f("thickness", _data[34]);
|
2024-05-25 07:01:54 +02:00
|
|
|
break;
|
|
|
|
|
2024-06-20 08:55:04 +02:00
|
|
|
case "Gear":
|
2024-08-08 06:57:51 +02:00
|
|
|
inputs[13].setVisible(true);
|
|
|
|
inputs[25].setVisible(true);
|
|
|
|
inputs[26].setVisible(true);
|
|
|
|
inputs[27].setVisible(true);
|
2024-06-20 08:55:04 +02:00
|
|
|
|
2024-08-08 06:57:51 +02:00
|
|
|
inputs[13].name = "Inner Radius";
|
2024-06-20 08:55:04 +02:00
|
|
|
|
|
|
|
shader_set_i("shape", 18);
|
|
|
|
shader_set_f("inner", _data[13]);
|
|
|
|
|
|
|
|
shader_set_i("teeth", _data[25]);
|
2024-06-24 13:49:54 +02:00
|
|
|
shader_set_2("teethSize", _data[26]);
|
2024-06-20 08:55:04 +02:00
|
|
|
shader_set_f("teethAngle", _data[27]);
|
|
|
|
break;
|
|
|
|
|
2024-09-14 07:37:19 +02:00
|
|
|
case "Squircle" :
|
|
|
|
inputs[31].setVisible(true);
|
|
|
|
|
|
|
|
shader_set_i("shape", 19);
|
|
|
|
shader_set_f("squircle_factor", abs(_data[31]));
|
|
|
|
break;
|
|
|
|
|
2024-10-09 09:22:48 +02:00
|
|
|
case "Half":
|
|
|
|
inputs[32].setVisible(true);
|
|
|
|
|
|
|
|
shader_set_i("shape", 21);
|
|
|
|
shader_set_2("point1", _data[32]);
|
|
|
|
break;
|
|
|
|
|
2024-08-07 04:16:09 +02:00
|
|
|
}
|
2022-01-13 05:24:03 +01:00
|
|
|
|
2023-10-23 11:39:41 +02:00
|
|
|
shader_set_f("dimension", _dim);
|
2024-01-07 12:18:20 +01:00
|
|
|
shader_set_f("bgColor", _bgcol);
|
|
|
|
shader_set_i("aa", _aa);
|
2024-08-25 10:18:22 +02:00
|
|
|
shader_set_i("drawBG", _bg);
|
2024-01-07 12:18:20 +01:00
|
|
|
shader_set_i("drawDF", _df);
|
2024-06-24 13:49:54 +02:00
|
|
|
shader_set_2("dfLevel", _level);
|
2024-01-07 12:18:20 +01:00
|
|
|
shader_set_i("tile", _tile);
|
|
|
|
shader_set_f("corner", _corner);
|
2024-08-26 06:54:36 +02:00
|
|
|
shader_set_f("w_curve", _curve);
|
|
|
|
shader_set_i("w_amount", array_length(_curve));
|
2023-10-23 11:39:41 +02:00
|
|
|
|
2024-06-24 13:49:54 +02:00
|
|
|
shader_set_2("center", _center);
|
|
|
|
shader_set_2("scale", _scale );
|
2024-08-25 10:18:22 +02:00
|
|
|
shader_set_f("shapeScale",_shpSca);
|
2024-01-22 14:23:35 +01:00
|
|
|
shader_set_f("rotation", degtorad(_rotat));
|
2022-08-30 07:36:37 +02:00
|
|
|
|
2024-01-08 08:10:50 +01:00
|
|
|
draw_sprite_stretched_ext(s_fx_pixel, 0, 0, 0, _dim[0], _dim[1], _color, _color_get_alpha(_color));
|
2023-10-23 11:39:41 +02:00
|
|
|
surface_reset_shader();
|
2022-12-27 04:00:50 +01:00
|
|
|
|
|
|
|
return _outSurf;
|
2024-08-07 04:16:09 +02:00
|
|
|
}
|
2024-10-09 06:38:35 +02:00
|
|
|
|
|
|
|
static postDeserialize = function() {
|
|
|
|
if(LOADING_VERSION < 1_18_01_0) {
|
|
|
|
var _dat = load_map.inputs[23].raw_value;
|
|
|
|
for( var i = 0, n = array_length(_dat); i < n; i++ )
|
|
|
|
_dat[i][1] = is_array(_dat[i][1])? array_safe_get(_dat[i][1], 1) : _dat[i][1];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
global.node_shape_keys_18 = [
|
|
|
|
"Rectangle", "Diamond", "Trapezoid", "Parallelogram",
|
|
|
|
-1, "Ellipse", "Arc", "Donut", "Crescent", "Disk Segment", "Pie", "Squircle",
|
|
|
|
-1, "Regular polygon", "Star", "Cross", "Rounded Cross",
|
|
|
|
-1, "Teardrop", "Leaf", "Heart", "Arrow", "Gear",
|
|
|
|
];
|