Pixel-Composer/scripts/node_rate_remap/node_rate_remap.gml

30 lines
986 B
Text
Raw Normal View History

2023-07-08 20:29:23 +02:00
function Node_Rate_Remap(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) constructor {
name = "Rate Remap";
2023-10-02 14:41:44 +02:00
use_cache = CACHE_USE.manual;
2023-07-08 20:29:23 +02:00
inputs[| 0] = nodeValue("Surface", self, JUNCTION_CONNECT.input, VALUE_TYPE.surface, noone);
inputs[| 1] = nodeValue("Framerate", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, 10);
inputs[| 2] = nodeValue("Active", self, JUNCTION_CONNECT.input, VALUE_TYPE.boolean, true);
active_index = 2;
outputs[| 0] = nodeValue("Surface", self, JUNCTION_CONNECT.output, VALUE_TYPE.surface, noone);
input_display_list = [ 2,
2023-12-23 09:39:55 +01:00
["Remap", false], 0, 1
2023-07-08 20:29:23 +02:00
];
2023-08-17 16:56:54 +02:00
static processData = function(_output, _data, _output_index, _array_index = 0) {
2023-07-08 20:29:23 +02:00
var _surf = _data[0];
var _rate = _data[1];
2023-10-09 16:07:33 +02:00
var _time = CURRENT_FRAME;
2023-07-08 20:29:23 +02:00
var _step = PROJECT.animator.framerate / _rate;
var _targ = floor(_time / _step) * _step;
cacheCurrentFrameIndex(_surf, _array_index);
var s = getCacheFrameIndex(_targ, _array_index);
return s;
}
}