mirror of
https://github.com/Ttanasart-pt/Pixel-Composer.git
synced 2024-12-24 14:06:23 +01:00
- [Canvas] Snap line now snap to integer ratio.
This commit is contained in:
parent
0f5ea22852
commit
3b76ff571c
5 changed files with 46 additions and 12 deletions
Binary file not shown.
|
@ -23,13 +23,36 @@ function canvas_tool_brush(brush, eraser = false) : canvas_tool() constructor {
|
|||
mouse_cur_y = round((_my - _y) / _s - 0.5);
|
||||
|
||||
if(mouse_pre_draw_x != undefined && mouse_pre_draw_y != undefined && key_mod_presses(SHIFT, CTRL)) {
|
||||
var aa = point_direction(mouse_pre_draw_x, mouse_pre_draw_y, mouse_cur_x, mouse_cur_y);
|
||||
var dd = point_distance(mouse_pre_draw_x, mouse_pre_draw_y, mouse_cur_x, mouse_cur_y);
|
||||
var _a = round(aa / 45) * 45;
|
||||
dd = dd * cos(degtorad(_a - aa));
|
||||
|
||||
var _dx = mouse_cur_x - mouse_pre_draw_x;
|
||||
var _dy = mouse_cur_y - mouse_pre_draw_y;
|
||||
|
||||
if(_dx != _dy) {
|
||||
var _ddx = _dx;
|
||||
var _ddy = _dy;
|
||||
|
||||
mouse_cur_x = mouse_pre_draw_x + lengthdir_x(dd, _a);
|
||||
mouse_cur_y = mouse_pre_draw_y + lengthdir_y(dd, _a);
|
||||
if(abs(_dx) > abs(_dy)) {
|
||||
var _rat = round(_ddx / _ddy);
|
||||
_ddx = _ddy * _rat;
|
||||
|
||||
} else {
|
||||
var _rat = round(_ddy / _ddx);
|
||||
_ddy = _ddx * _rat;
|
||||
|
||||
}
|
||||
|
||||
mouse_cur_x = mouse_pre_draw_x + _ddx - sign(_ddx);
|
||||
mouse_cur_y = mouse_pre_draw_y + _ddy - sign(_ddy);
|
||||
|
||||
// var aa = point_direction(mouse_pre_draw_x, mouse_pre_draw_y, mouse_cur_x, mouse_cur_y);
|
||||
// var dd = point_distance(mouse_pre_draw_x, mouse_pre_draw_y, mouse_cur_x, mouse_cur_y);
|
||||
|
||||
// var _a = round(aa / 45) * 45;
|
||||
// dd = dd * dcos(_a - aa);
|
||||
|
||||
// mouse_cur_x = mouse_pre_draw_x + lengthdir_x(dd, _a);
|
||||
// mouse_cur_y = mouse_pre_draw_y + lengthdir_y(dd, _a);
|
||||
}
|
||||
}
|
||||
|
||||
if(mouse_press(mb_left, active)) {
|
||||
|
@ -113,6 +136,7 @@ function canvas_tool_brush(brush, eraser = false) : canvas_tool() constructor {
|
|||
var _h = mouse_line_y1 - mouse_line_y0;
|
||||
var _as = max(_w, _h) % min(_w, _h) == 0;
|
||||
|
||||
draw_set_alpha(0.5);
|
||||
draw_set_color(_as? COLORS._main_value_positive : COLORS._main_accent);
|
||||
draw_rectangle(_x0, _y0, _x1, _y1, true);
|
||||
|
||||
|
@ -121,6 +145,6 @@ function canvas_tool_brush(brush, eraser = false) : canvas_tool() constructor {
|
|||
|
||||
draw_set_text(f_p3, fa_left, fa_center);
|
||||
draw_text(_x1 + 8, (_y0 + _y1) / 2, _h);
|
||||
|
||||
draw_set_alpha(1);
|
||||
}
|
||||
}
|
|
@ -91,6 +91,7 @@ function canvas_tool_shape(brush, shape) : canvas_tool() constructor {
|
|||
|
||||
var _as = max(_w, _h) % min(_w, _h) == 0;
|
||||
|
||||
draw_set_alpha(0.5);
|
||||
draw_set_color(_as? COLORS._main_value_positive : COLORS._main_accent);
|
||||
draw_rectangle(_x0, _y0, _x1, _y1, true);
|
||||
|
||||
|
@ -99,5 +100,6 @@ function canvas_tool_shape(brush, shape) : canvas_tool() constructor {
|
|||
|
||||
draw_set_text(f_p3, fa_left, fa_center);
|
||||
draw_text(_x1 + 8, (_y0 + _y1) / 2, _h);
|
||||
draw_set_alpha(1);
|
||||
}
|
||||
}
|
|
@ -284,13 +284,17 @@ function Node_Canvas_Group(_x, _y, _group) : Node_Collection(_x, _y, _group) con
|
|||
timeline_item_group.color = getColor();
|
||||
}
|
||||
|
||||
for (var i = 0, n = array_length(canvases); i < n; i++) {
|
||||
for (var i = 0, n = array_length(canvases); i < n; i++)
|
||||
canvases[i].attributes.show_slope_check = attributes.show_slope_check;
|
||||
}
|
||||
}
|
||||
|
||||
static update = function() {
|
||||
refreshLayer();
|
||||
|
||||
var _dim = getInputData(0);
|
||||
|
||||
for (var i = 0, n = array_length(canvases); i < n; i++)
|
||||
canvases[i].inputs[| 0].setValue(_dim);
|
||||
}
|
||||
|
||||
static getPreviewValues = function() { return composite == noone? noone : composite.getPreviewValues(); }
|
||||
|
|
|
@ -1,8 +1,12 @@
|
|||
function GCD(num1, num2) {
|
||||
if(num1 * num2 == 0) return 0;
|
||||
if(num1 * num2 == 0) return 1;
|
||||
|
||||
if (num2 == 0) return num1;
|
||||
else return GCD(num2, num1 % num2);
|
||||
var n1 = max(num1, num2);
|
||||
var n2 = min(num1, num2);
|
||||
var nn = n1 % n2;
|
||||
|
||||
if(nn == 0) return n2;
|
||||
return GCD(n2, nn);
|
||||
}
|
||||
|
||||
function GCDs(num1, num2) {
|
||||
|
|
Loading…
Reference in a new issue