Pixel-Composer/scripts/node_rate_remap/node_rate_remap.gml

31 lines
873 B
Plaintext
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
2024-08-18 06:16:20 +02:00
newInput(0, nodeValue_Surface("Surface", self));
2023-07-08 20:29:23 +02:00
2024-08-18 09:13:41 +02:00
newInput(1, nodeValue_Float("Framerate", self, 10))
.setValidator(VV_min(1));
2023-07-08 20:29:23 +02:00
2024-08-18 06:16:20 +02:00
newInput(2, nodeValue_Bool("Active", self, true));
2023-07-08 20:29:23 +02:00
active_index = 2;
2024-09-04 03:57:11 +02:00
newOutput(0, nodeValue_Output("Surface", self, VALUE_TYPE.surface, noone));
2023-07-08 20:29:23 +02:00
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;
}
}