mirror of
https://github.com/Ttanasart-pt/Pixel-Composer.git
synced 2024-12-26 23:17:25 +01:00
74 lines
No EOL
2.2 KiB
Text
74 lines
No EOL
2.2 KiB
Text
function canvas_tool_outline() : canvas_tool_shader() constructor {
|
|
|
|
mouse_sx = 0;
|
|
|
|
function init() { mouse_init = true; }
|
|
|
|
function onInit(hover, active, _x, _y, _s, _mx, _my, _snx, _sny) {
|
|
mouse_sx = _mx;
|
|
}
|
|
|
|
function stepEffect(hover, active, _x, _y, _s, _mx, _my, _snx, _sny) {
|
|
var _dim = node.attributes.dimension;
|
|
|
|
var _thck = abs(round((_mx - mouse_sx) / _s));
|
|
var _side = _mx > mouse_sx;
|
|
|
|
surface_set_shader(preview_surface[1], sh_outline);
|
|
|
|
shader_set_f("dimension", _dim);
|
|
shader_set_f("borderSize", _thck, _thck);
|
|
shader_set_f("borderStart", 0, 0);
|
|
shader_set_i("side", _side);
|
|
shader_set_i("filter", array_create(9, 1));
|
|
shader_set_color("borderColor", CURRENT_COLOR);
|
|
|
|
draw_surface_safe(preview_surface[0]);
|
|
surface_reset_shader();
|
|
}
|
|
|
|
function stepMaskEffect(hover, active, _x, _y, _s, _mx, _my, _snx, _sny) {
|
|
var _dim = node.attributes.dimension;
|
|
|
|
var _thck = abs(round((_mx - mouse_sx) / _s));
|
|
var _side = _mx > mouse_sx;
|
|
|
|
if(_side) {
|
|
surface_set_shader(preview_surface[1], sh_outline);
|
|
|
|
shader_set_f("dimension", _dim);
|
|
shader_set_f("borderSize", _thck, _thck);
|
|
shader_set_f("borderStart", 0, 0);
|
|
shader_set_i("side", _side);
|
|
shader_set_i("filter", array_create(9, 1));
|
|
shader_set_color("borderColor", c_white);
|
|
|
|
draw_surface_safe(preview_surface[0]);
|
|
surface_reset_shader();
|
|
|
|
mask_boundary[0] = mask_boundary_init[0] - _thck;
|
|
mask_boundary[1] = mask_boundary_init[1] - _thck;
|
|
mask_boundary[2] = mask_boundary_init[2] + _thck * 2;
|
|
mask_boundary[3] = mask_boundary_init[3] + _thck * 2;
|
|
|
|
} else {
|
|
surface_set_shader(preview_surface[1], sh_erode);
|
|
|
|
shader_set_f("dimension", _dim);
|
|
shader_set_f("size", _thck, _thck);
|
|
shader_set_i("border", 0);
|
|
shader_set_i("alpha", 1);
|
|
|
|
draw_surface_safe(preview_surface[0]);
|
|
surface_reset_shader();
|
|
|
|
mask_boundary[0] = mask_boundary_init[0] + _thck;
|
|
mask_boundary[1] = mask_boundary_init[1] + _thck;
|
|
mask_boundary[2] = mask_boundary_init[2] - _thck * 2;
|
|
mask_boundary[3] = mask_boundary_init[3] - _thck * 2;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} |