mirror of
https://github.com/Ttanasart-pt/Pixel-Composer.git
synced 2024-11-14 06:23:55 +01:00
73 lines
2.3 KiB
Plaintext
73 lines
2.3 KiB
Plaintext
function Node_FLIP_Repel(_x, _y, _group = noone) : Node(_x, _y, _group) constructor {
|
|
name = "Repel";
|
|
color = COLORS.node_blend_fluid;
|
|
icon = THEME.fluid_sim;
|
|
setDimension(96, 96);
|
|
|
|
manual_ungroupable = false;
|
|
|
|
inputs[| 0] = nodeValue("Domain", self, JUNCTION_CONNECT.input, VALUE_TYPE.fdomain, noone )
|
|
.setVisible(true, true);
|
|
|
|
inputs[| 1] = nodeValue("Position", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, [ 0, 0 ] )
|
|
.setDisplay(VALUE_DISPLAY.vector)
|
|
.setUnitRef(function(index) { return getDimension(); });
|
|
|
|
inputs[| 2] = nodeValue("Radius", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, 4 );
|
|
|
|
inputs[| 3] = nodeValue("Strength", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, 4 )
|
|
.setDisplay(VALUE_DISPLAY.slider, { range: [ 0, 16, 0.1 ] });
|
|
|
|
input_display_list = [ 0,
|
|
["Repel", false], 1, 2, 3,
|
|
]
|
|
|
|
outputs[| 0] = nodeValue("Domain", self, JUNCTION_CONNECT.output, VALUE_TYPE.fdomain, noone );
|
|
|
|
static getDimension = function() { #region
|
|
var domain = getInputData(0);
|
|
if(!instance_exists(domain)) return [ 1, 1 ];
|
|
|
|
return [ domain.width, domain.height ];
|
|
} #endregion
|
|
|
|
static drawOverlay = function(hover, active, _x, _y, _s, _mx, _my, _snx, _sny) { #region
|
|
var _posit = getInputData(1);
|
|
var _rad = getInputData(2);
|
|
|
|
var _px = _x + _posit[0] * _s;
|
|
var _py = _y + _posit[1] * _s;
|
|
|
|
var _r = _rad * _s;
|
|
|
|
draw_set_color(COLORS._main_accent);
|
|
draw_circle_prec(_px, _py, _r, true, 32);
|
|
|
|
if(inputs[| 1].drawOverlay(hover, active, _x, _y, _s, _mx, _my, _snx, _sny)) { hover = false; active = false; }
|
|
|
|
} #endregion
|
|
|
|
static step = function() { #region
|
|
|
|
} #endregion
|
|
|
|
static update = function(frame = CURRENT_FRAME) { #region
|
|
var domain = getInputData(0);
|
|
if(!instance_exists(domain)) return;
|
|
|
|
outputs[| 0].setValue(domain);
|
|
|
|
var _posit = getInputData(1);
|
|
var _rad = getInputData(2);
|
|
var _str = getInputData(3);
|
|
|
|
FLIP_Repel(domain.domain, _posit[0], _posit[1], _rad, _str * 8);
|
|
} #endregion
|
|
|
|
static onDrawNode = function(xx, yy, _mx, _my, _s, _hover, _focus) {
|
|
var bbox = drawGetBbox(xx, yy, _s);
|
|
draw_sprite_fit(s_node_fluidSim_repulse, 0, bbox.xc, bbox.yc, bbox.w, bbox.h);
|
|
}
|
|
|
|
static getPreviewValues = function() { var domain = getInputData(0); return instance_exists(domain)? domain.domain_preview : noone; }
|
|
} |