2024-04-13 07:32:04 +02:00
|
|
|
function canvas_tool_inset() : canvas_tool_shader() constructor {
|
|
|
|
|
|
|
|
mouse_sx = 0;
|
|
|
|
mouse_sy = 0;
|
|
|
|
|
|
|
|
function init() { mouse_init = true; }
|
|
|
|
|
|
|
|
function onInit(hover, active, _x, _y, _s, _mx, _my, _snx, _sny) {
|
|
|
|
mouse_sx = _mx;
|
|
|
|
mouse_sy = _my;
|
|
|
|
}
|
|
|
|
|
|
|
|
function stepEffect(hover, active, _x, _y, _s, _mx, _my, _snx, _sny) {
|
|
|
|
var _dim = node.attributes.dimension;
|
|
|
|
|
|
|
|
var _dx = (_mx - mouse_sx) / _s;
|
|
|
|
var _dy = (_my - mouse_sy) / _s;
|
|
|
|
|
|
|
|
if(key_mod_press(CTRL)) {
|
|
|
|
var ang = point_direction(0, 0, _dx, _dy);
|
|
|
|
var dist = point_distance(0, 0, _dx, _dy);
|
|
|
|
ang = round(ang / 45) * 45;
|
|
|
|
|
|
|
|
_dx = lengthdir_x(dist, ang);
|
|
|
|
_dy = lengthdir_y(dist, ang);
|
|
|
|
}
|
|
|
|
|
|
|
|
surface_set_shader(preview_surface[1], sh_canvas_inset);
|
|
|
|
|
|
|
|
shader_set_f("dimension", _dim);
|
|
|
|
shader_set_f("shift", _dx, _dy);
|
|
|
|
shader_set_f("itr", round(sqrt(_dx * _dx + _dy * _dy)));
|
2024-05-15 12:42:54 +02:00
|
|
|
shader_set_color("color", node.CURRENT_COLOR);
|
2024-04-13 07:32:04 +02:00
|
|
|
|
|
|
|
draw_surface(preview_surface[0], 0, 0);
|
|
|
|
surface_reset_shader();
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|