2023-07-08 20:29:23 +02:00
|
|
|
function Node_Onion_Skin(_x, _y, _group = noone) : Node(_x, _y, _group) constructor {
|
|
|
|
name = "Onion Skin";
|
2023-10-02 14:41:44 +02:00
|
|
|
use_cache = CACHE_USE.manual;
|
2023-07-08 20:29:23 +02:00
|
|
|
clearCacheOnChange = false;
|
|
|
|
|
2024-08-18 06:16:20 +02:00
|
|
|
newInput(0, nodeValue_Surface("Surface in", self));
|
2023-07-08 20:29:23 +02:00
|
|
|
|
2024-08-18 06:16:20 +02:00
|
|
|
newInput(1, nodeValue_Slider_Range("Range", self, [-1, 1], { range: [ -16, 16, 0.1 ] }));
|
2023-07-08 20:29:23 +02:00
|
|
|
|
2024-08-18 09:13:41 +02:00
|
|
|
newInput(2, nodeValue_Float("Alpha", self, 0.5))
|
2023-10-02 08:57:44 +02:00
|
|
|
.setDisplay(VALUE_DISPLAY.slider);
|
2023-07-08 20:29:23 +02:00
|
|
|
|
2024-11-23 08:31:15 +01:00
|
|
|
newInput(3, nodeValue_Color("Color pre", self, cola(c_red)))
|
2023-07-08 20:29:23 +02:00
|
|
|
|
2024-11-23 08:31:15 +01:00
|
|
|
newInput(4, nodeValue_Color("Color post", self, cola(c_blue)))
|
2023-07-08 20:29:23 +02:00
|
|
|
|
2024-08-18 09:13:41 +02:00
|
|
|
newInput(5, nodeValue_Int("Step", self, 1))
|
2023-07-08 20:29:23 +02:00
|
|
|
|
2024-08-18 09:13:41 +02:00
|
|
|
newInput(6, nodeValue_Bool("On top", self, true, "Render current frame on top of all frames."))
|
2023-07-08 20:29:23 +02:00
|
|
|
|
2024-09-04 03:57:11 +02:00
|
|
|
newOutput(0, nodeValue_Output("Output", self, VALUE_TYPE.surface, noone));
|
2023-07-08 20:29:23 +02:00
|
|
|
|
|
|
|
input_display_list = [
|
|
|
|
["Surface", false], 0, 1, 5,
|
|
|
|
["Render", false], 2, 3, 4, 6,
|
|
|
|
];
|
|
|
|
|
2024-11-26 05:52:57 +01:00
|
|
|
setTrigger(2, "Clear cache", [ THEME.cache, 0, COLORS._main_icon ]);
|
2023-07-08 20:29:23 +02:00
|
|
|
|
|
|
|
static onInspector2Update = function() { clearCache(); }
|
|
|
|
|
|
|
|
static update = function() {
|
2024-08-08 06:57:51 +02:00
|
|
|
if(!inputs[0].value_from) return;
|
2023-07-08 20:29:23 +02:00
|
|
|
|
2023-10-02 08:57:44 +02:00
|
|
|
var _surf = getInputData(0);
|
|
|
|
var _rang = getInputData(1);
|
2023-07-08 20:29:23 +02:00
|
|
|
|
2023-10-02 08:57:44 +02:00
|
|
|
var _alph = getInputData(2);
|
|
|
|
var _cpre = getInputData(3);
|
|
|
|
var _cpos = getInputData(4);
|
2023-07-08 20:29:23 +02:00
|
|
|
|
2023-10-02 08:57:44 +02:00
|
|
|
var _step = getInputData(5);
|
|
|
|
var _top = getInputData(6);
|
2023-07-08 20:29:23 +02:00
|
|
|
cacheCurrentFrame(_surf);
|
|
|
|
|
2024-08-08 06:57:51 +02:00
|
|
|
var _outSurf = outputs[0].getValue();
|
2023-09-08 21:37:36 +02:00
|
|
|
_outSurf = surface_verify(_outSurf, surface_get_width_safe(_surf), surface_get_height_safe(_surf));
|
2024-08-08 06:57:51 +02:00
|
|
|
outputs[0].setValue(_outSurf);
|
2023-07-08 20:29:23 +02:00
|
|
|
|
|
|
|
surface_set_target(_outSurf);
|
|
|
|
DRAW_CLEAR
|
|
|
|
|
2023-10-09 16:07:33 +02:00
|
|
|
var fr = CURRENT_FRAME;
|
2023-07-08 20:29:23 +02:00
|
|
|
var st = min(_rang[0], _rang[1]);
|
|
|
|
var ed = max(_rang[0], _rang[1]);
|
|
|
|
|
|
|
|
st = sign(st) * floor(abs(st) / _step) * _step;
|
|
|
|
ed = sign(ed) * floor(abs(ed) / _step) * _step;
|
|
|
|
|
|
|
|
st += fr;
|
|
|
|
ed += fr;
|
|
|
|
|
|
|
|
for( var i = st; i <= ed; i += _step ) {
|
|
|
|
var surf = getCacheFrame(i);
|
|
|
|
if(!is_surface(surf)) continue;
|
|
|
|
|
|
|
|
var aa = power(_alph, abs(i - fr));
|
|
|
|
var cc = c_white;
|
|
|
|
if(i < fr) cc = _cpre;
|
|
|
|
else if(i > fr) cc = _cpos;
|
|
|
|
|
|
|
|
draw_surface_ext_safe(surf, 0, 0, 1, 1, 0, cc, aa);
|
|
|
|
}
|
|
|
|
|
2024-07-10 03:45:25 +02:00
|
|
|
if(_top) draw_surface_safe(_surf);
|
2023-07-08 20:29:23 +02:00
|
|
|
surface_reset_target();
|
|
|
|
}
|
|
|
|
}
|