Pixel-Composer/scripts/node_vector/node_vector.gml

209 lines
6.9 KiB
Plaintext
Raw Normal View History

2022-12-27 04:00:50 +01:00
function Node_Number(_x, _y, _group = -1) : Node_Processor(_x, _y, _group) constructor {
2022-01-13 05:24:03 +01:00
name = "Number";
2022-11-18 03:20:31 +01:00
color = COLORS.node_blend_number;
2022-01-13 05:24:03 +01:00
previewable = false;
w = 96;
min_h = 32 + 24 * 1;
2022-01-19 03:05:13 +01:00
inputs[| 0] = nodeValue(0, "Value", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, 0)
.setVisible(true, true);
2022-01-13 05:24:03 +01:00
outputs[| 0] = nodeValue(0, "Number", self, JUNCTION_CONNECT.output, VALUE_TYPE.float, 0);
2023-01-01 02:06:02 +01:00
static drawOverlay = function(active, _x, _y, _s, _mx, _my, _snx, _sny) {
inputs[| 0].drawOverlay(active, _x, _y, _s, _mx, _my, _snx, _sny);
}
2022-12-27 04:00:50 +01:00
function process_data(_output, _data, index = 0) {
2022-01-13 05:24:03 +01:00
return _data[0];
}
static onDrawNode = function(xx, yy, _mx, _my, _s) {
2022-11-18 03:20:31 +01:00
draw_set_text(f_h5, fa_center, fa_center, COLORS._main_text);
2023-01-01 02:06:02 +01:00
var str = string(outputs[| 0].getValue());
2022-01-13 05:24:03 +01:00
var ss = string_scale(str, (w - 16) * _s, (h - 16) * _s - 20);
draw_text_transformed(xx + w / 2 * _s, yy + 10 + h / 2 * _s, str, ss, ss, 0);
}
}
2022-12-27 04:00:50 +01:00
function Node_Vector2(_x, _y, _group = -1) : Node_Processor(_x, _y, _group) constructor {
2022-01-13 05:24:03 +01:00
name = "Vector2";
2022-11-18 03:20:31 +01:00
color = COLORS.node_blend_number;
2022-01-13 05:24:03 +01:00
previewable = false;
w = 96;
min_h = 32 + 24 * 2;
2022-01-19 03:05:13 +01:00
inputs[| 0] = nodeValue(0, "x", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, 0)
.setVisible(true, true);
inputs[| 1] = nodeValue(1, "y", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, 0)
.setVisible(true, true);
2022-01-13 05:24:03 +01:00
2023-01-01 02:06:02 +01:00
outputs[| 0] = nodeValue(0, "Vector", self, JUNCTION_CONNECT.output, VALUE_TYPE.float, [ 0, 0 ])
.setDisplay(VALUE_DISPLAY.vector);
drag_type = 0;
drag_mx = 0;
drag_my = 0;
drag_sx = 0;
drag_sy = 0;
static drawOverlay = function(active, _x, _y, _s, _mx, _my, _snx, _sny) {
var __ax = inputs[| 0].getValue();
var __ay = inputs[| 1].getValue();
var _ax = __ax * _s + _x;
var _ay = __ay * _s + _y;
var _val;
draw_sprite_ui_uniform(THEME.anchor_selector, 0, _ax, _ay);
if(drag_type) {
draw_sprite_ui_uniform(THEME.anchor_selector, 1, _ax, _ay);
var _nx = value_snap((drag_sx + (_mx - drag_mx) - _x) / _s, _snx);
var _ny = value_snap((drag_sy + (_my - drag_my) - _y) / _s, _sny);
if(key_mod_press(CTRL)) {
_val[0] = round(_nx);
_val[1] = round(_ny);
} else {
_val[0] = _nx;
_val[1] = _ny;
}
var s0 = inputs[| 0].setValue(_val[0]);
var s1 = inputs[| 1].setValue(_val[1]);
if(s0 || s1)
UNDO_HOLDING = true;
if(mouse_release(mb_left)) {
drag_type = 0;
UNDO_HOLDING = false;
}
}
if(point_in_circle(_mx, _my, _ax, _ay, 8)) {
hover = 1;
draw_sprite_ui_uniform(THEME.anchor_selector, 1, _ax, _ay);
if(mouse_press(mb_left, active)) {
drag_type = 1;
drag_mx = _mx;
drag_my = _my;
drag_sx = _ax;
drag_sy = _ay;
}
}
}
2022-01-13 05:24:03 +01:00
2022-12-27 04:00:50 +01:00
function process_data(_output, _data, index = 0) {
2022-01-13 05:24:03 +01:00
var vec = [ _data[0], _data[1] ];
return vec;
}
static onDrawNode = function(xx, yy, _mx, _my, _s) {
2022-11-18 03:20:31 +01:00
draw_set_text(f_p0, fa_center, fa_center, COLORS._main_text);
2023-01-01 02:06:02 +01:00
var vec = outputs[| 0].getValue();
var str = string(vec[0]) + "\n" + string(vec[1]);
2022-01-13 05:24:03 +01:00
var ss = string_scale(str, (w - 16) * _s, (h - 16) * _s - 20);
draw_text_transformed(xx + w / 2 * _s, yy + 10 + h / 2 * _s, str, ss, ss, 0);
}
}
2022-12-27 04:00:50 +01:00
function Node_Vector3(_x, _y, _group = -1) : Node_Processor(_x, _y, _group) constructor {
2022-01-13 05:24:03 +01:00
name = "Vector3";
2022-11-18 03:20:31 +01:00
color = COLORS.node_blend_number;
2022-01-13 05:24:03 +01:00
previewable = false;
w = 96;
min_h = 32 + 24 * 3;
2022-01-19 03:05:13 +01:00
inputs[| 0] = nodeValue(0, "x", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, 0)
.setVisible(true, true);
inputs[| 1] = nodeValue(1, "y", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, 0)
.setVisible(true, true);
inputs[| 2] = nodeValue(2, "z", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, 0)
.setVisible(true, true);
2022-01-13 05:24:03 +01:00
outputs[| 0] = nodeValue(0, "Vector", self, JUNCTION_CONNECT.output, VALUE_TYPE.float, [ 0, 0, 0 ])
.setDisplay(VALUE_DISPLAY.vector);
2022-12-27 04:00:50 +01:00
function process_data(_output, _data, index = 0) {
2022-01-13 05:24:03 +01:00
var vec = [ _data[0], _data[1], _data[2] ];
return vec;
}
static onDrawNode = function(xx, yy, _mx, _my, _s) {
2022-11-18 03:20:31 +01:00
draw_set_text(f_p0, fa_center, fa_center, COLORS._main_text);
2023-01-01 02:06:02 +01:00
var vec = outputs[| 0].getValue();
var str = string(vec[0]) + "\n" + string(vec[1]) + "\n" + string(vec[2]);
2022-01-13 05:24:03 +01:00
var ss = string_scale(str, (w - 16) * _s, (h - 16) * _s - 20);
draw_text_transformed(xx + w / 2 * _s, yy + 10 + h / 2 * _s, str, ss, ss, 0);
}
}
2022-12-27 04:00:50 +01:00
function Node_Vector4(_x, _y, _group = -1) : Node_Processor(_x, _y, _group) constructor {
2022-01-13 05:24:03 +01:00
name = "Vector4";
2022-11-18 03:20:31 +01:00
color = COLORS.node_blend_number;
2022-01-13 05:24:03 +01:00
previewable = false;
w = 96;
min_h = 32 + 24 * 4;
2022-01-19 03:05:13 +01:00
inputs[| 0] = nodeValue(0, "x", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, 0)
.setVisible(true, true);
inputs[| 1] = nodeValue(1, "y", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, 0)
.setVisible(true, true);
inputs[| 2] = nodeValue(2, "z", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, 0)
.setVisible(true, true);
inputs[| 3] = nodeValue(3, "w", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, 0)
.setVisible(true, true);
2022-01-13 05:24:03 +01:00
outputs[| 0] = nodeValue(0, "Vector", self, JUNCTION_CONNECT.output, VALUE_TYPE.float, [ 0, 0, 0, 0 ])
.setDisplay(VALUE_DISPLAY.vector);
2022-12-27 04:00:50 +01:00
function process_data(_output, _data, index = 0) {
2022-01-13 05:24:03 +01:00
var vec = [ _data[0], _data[1], _data[2], _data[3] ];
return vec;
}
static onDrawNode = function(xx, yy, _mx, _my, _s) {
2022-11-18 03:20:31 +01:00
draw_set_text(f_p0, fa_center, fa_center, COLORS._main_text);
2023-01-01 02:06:02 +01:00
var vec = outputs[| 0].getValue();
var str = string(vec[0]) + "\n" + string(vec[1]) + "\n" + string(vec[2]) + "\n" + string(vec[3]);
2022-01-13 05:24:03 +01:00
var ss = string_scale(str, (w - 16) * _s, (h - 16) * _s - 20);
draw_text_transformed(xx + w / 2 * _s, yy + 10 + h / 2 * _s, str, ss, ss, 0);
}
}
2022-12-27 04:00:50 +01:00
function Node_Vector_Split(_x, _y, _group = -1) : Node_Processor(_x, _y, _group) constructor {
2022-01-13 05:24:03 +01:00
name = "Vector split";
2022-11-18 03:20:31 +01:00
color = COLORS.node_blend_number;
2022-01-13 05:24:03 +01:00
previewable = false;
w = 96;
min_h = 32 + 24 * 4;
inputs[| 0] = nodeValue(0, "Vector", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, [ 0, 0, 0, 0 ])
2022-01-19 03:05:13 +01:00
.setDisplay(VALUE_DISPLAY.vector)
.setVisible(true, true);
2022-01-13 05:24:03 +01:00
outputs[| 0] = nodeValue(0, "x", self, JUNCTION_CONNECT.output, VALUE_TYPE.float, 0);
outputs[| 1] = nodeValue(1, "y", self, JUNCTION_CONNECT.output, VALUE_TYPE.float, 0);
outputs[| 2] = nodeValue(2, "z", self, JUNCTION_CONNECT.output, VALUE_TYPE.float, 0);
outputs[| 3] = nodeValue(3, "w", self, JUNCTION_CONNECT.output, VALUE_TYPE.float, 0);
2022-12-27 04:00:50 +01:00
function process_data(_output, _data, _index = 0) {
2022-01-13 05:24:03 +01:00
if(array_length(_data[0]) > _index)
return _data[0][_index];
return 0;
}
static onDrawNode = function(xx, yy, _mx, _my, _s) {
2022-11-18 03:20:31 +01:00
draw_set_text(f_p0, fa_center, fa_center, COLORS._main_text);
2022-01-13 05:24:03 +01:00
var str = string(outputs[| 0].getValue()) + "\n" + string(outputs[| 1].getValue())
+ "\n" + string(outputs[| 2].getValue()) + "\n" + string(outputs[| 3].getValue());
var ss = string_scale(str, (w - 16) * _s, (h - 16) * _s - 20);
draw_text_transformed(xx + w / 2 * _s, yy + 10 + h / 2 * _s, str, ss, ss, 0);
}
}