mirror of
https://github.com/Ttanasart-pt/Pixel-Composer.git
synced 2024-11-14 22:43:53 +01:00
95 lines
2.6 KiB
Plaintext
95 lines
2.6 KiB
Plaintext
|
function Node_Fn(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) constructor {
|
||
|
name = "Fn";
|
||
|
update_on_frame = true;
|
||
|
setDimension(96, 96);
|
||
|
|
||
|
inputs[| 0] = nodeValue("Display", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, 1 )
|
||
|
.setDisplay(VALUE_DISPLAY.enum_scroll, [ "Number", "Graph" ]);
|
||
|
|
||
|
outputs[| 0] = nodeValue("Output", self, JUNCTION_CONNECT.output, VALUE_TYPE.float, 0);
|
||
|
|
||
|
inl = ds_list_size(inputs);
|
||
|
|
||
|
input_display_list = [
|
||
|
["Display", true], 0,
|
||
|
];
|
||
|
|
||
|
text_display = 0;
|
||
|
graph_display = array_create(64, 0);
|
||
|
graph_display_min = 0;
|
||
|
graph_display_max = 0;
|
||
|
|
||
|
static __fnEval = function(_x = 0) { return 0; }
|
||
|
|
||
|
static refreshDisplay = function() {
|
||
|
graph_display_min = undefined;
|
||
|
graph_display_max = undefined;
|
||
|
|
||
|
for( var i = 0; i < 64; i++ ) {
|
||
|
var _c = __fnEval(i / 64);
|
||
|
graph_display[i] = _c;
|
||
|
graph_display_min = graph_display_min == undefined? _c : min(graph_display_min, _c);
|
||
|
graph_display_max = graph_display_max == undefined? _c : max(graph_display_max, _c);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
static postPostProcess = function() { if(!IS_PLAYING) refreshDisplay(); }
|
||
|
|
||
|
static processData = function(_output, _data, _output_index, _array_index = 0) { }
|
||
|
|
||
|
static onDrawNode = function(xx, yy, _mx, _my, _s, _hover, _focus) { #region
|
||
|
var bbox = drawGetBbox(xx, yy, _s);
|
||
|
|
||
|
var disp = array_safe_get_fast(current_data, 0);
|
||
|
var time = CURRENT_FRAME;
|
||
|
var total_time = TOTAL_FRAMES;
|
||
|
|
||
|
switch(disp) {
|
||
|
case 0 :
|
||
|
draw_set_text(f_sdf, fa_center, fa_center, COLORS._main_text);
|
||
|
draw_text_bbox(bbox, text_display);
|
||
|
break;
|
||
|
|
||
|
case 1 :
|
||
|
var _min = graph_display_min;
|
||
|
var _max = graph_display_max;
|
||
|
var val = (_min + _max) / 2;
|
||
|
var _ran = _max - _min;
|
||
|
|
||
|
var x0 = bbox.x0;
|
||
|
var x1 = bbox.x1;
|
||
|
var y0 = bbox.y0;
|
||
|
var y1 = bbox.y1;
|
||
|
var ww = bbox.w;
|
||
|
var hh = bbox.h;
|
||
|
|
||
|
var yc = (y0 + y1) / 2;
|
||
|
draw_set_color(COLORS.node_wiggler_frame);
|
||
|
draw_set_alpha(0.5);
|
||
|
draw_line(x0, yc, x1, yc);
|
||
|
draw_set_alpha(1);
|
||
|
|
||
|
draw_set_text(f_sdf, fa_right, fa_bottom, COLORS._main_text_sub);
|
||
|
draw_text_transformed(x1 - 2 * _s, y1, text_display, 0.3 * _s, 0.3 * _s, 0);
|
||
|
|
||
|
var lw = ww / (64 - 1);
|
||
|
var ox, oy;
|
||
|
draw_set_color(c_white);
|
||
|
for( var i = 0; i < 64; i++ ) {
|
||
|
var _x = x0 + i * lw;
|
||
|
var _y = yc - (graph_display[i] - val) / _ran * hh;
|
||
|
if(i) draw_line(ox, oy, _x, _y);
|
||
|
|
||
|
ox = _x;
|
||
|
oy = _y;
|
||
|
}
|
||
|
draw_set_color(COLORS._main_accent);
|
||
|
var _fx = x0 + (time / total_time * ww);
|
||
|
draw_line(_fx, y0, _fx, y1);
|
||
|
|
||
|
draw_set_color(COLORS.node_wiggler_frame);
|
||
|
draw_rectangle(x0, y0, x1, y1, true);
|
||
|
break;
|
||
|
}
|
||
|
} #endregion
|
||
|
}
|