mirror of
https://github.com/Ttanasart-pt/Pixel-Composer.git
synced 2024-12-25 14:36:13 +01:00
slope check
This commit is contained in:
parent
1daa21a32e
commit
0b6740d2c9
6 changed files with 148 additions and 24 deletions
|
@ -1,4 +1,4 @@
|
||||||
// 2024-04-14 18:56:07
|
// 2024-04-18 15:44:33
|
||||||
function canvas_tool_brush(brush, eraser = false) : canvas_tool() constructor {
|
function canvas_tool_brush(brush, eraser = false) : canvas_tool() constructor {
|
||||||
self.brush = brush;
|
self.brush = brush;
|
||||||
isEraser = eraser;
|
isEraser = eraser;
|
||||||
|
@ -12,6 +12,12 @@ function canvas_tool_brush(brush, eraser = false) : canvas_tool() constructor {
|
||||||
mouse_pre_draw_x = undefined;
|
mouse_pre_draw_x = undefined;
|
||||||
mouse_pre_draw_y = undefined;
|
mouse_pre_draw_y = undefined;
|
||||||
|
|
||||||
|
mouse_line_drawing = false;
|
||||||
|
mouse_line_x0 = 0;
|
||||||
|
mouse_line_y0 = 0;
|
||||||
|
mouse_line_x1 = 0;
|
||||||
|
mouse_line_y1 = 0;
|
||||||
|
|
||||||
function step(hover, active, _x, _y, _s, _mx, _my, _snx, _sny) {
|
function step(hover, active, _x, _y, _s, _mx, _my, _snx, _sny) {
|
||||||
|
|
||||||
mouse_cur_x = round((_mx - _x) / _s - 0.5);
|
mouse_cur_x = round((_mx - _x) / _s - 0.5);
|
||||||
|
@ -30,13 +36,13 @@ function canvas_tool_brush(brush, eraser = false) : canvas_tool() constructor {
|
||||||
if(mouse_press(mb_left, active)) {
|
if(mouse_press(mb_left, active)) {
|
||||||
|
|
||||||
surface_set_shader(drawing_surface, noone);
|
surface_set_shader(drawing_surface, noone);
|
||||||
canvas_draw_point_size(brush, mouse_cur_x, mouse_cur_y, true);
|
canvas_draw_point_brush(brush, mouse_cur_x, mouse_cur_y, true);
|
||||||
surface_reset_shader();
|
surface_reset_shader();
|
||||||
|
|
||||||
mouse_holding = true;
|
mouse_holding = true;
|
||||||
if(mouse_pre_draw_x != undefined && mouse_pre_draw_y != undefined && key_mod_press(SHIFT)) { ///////////////// shift line
|
if(mouse_pre_draw_x != undefined && mouse_pre_draw_y != undefined && key_mod_press(SHIFT)) { ///////////////// shift line
|
||||||
surface_set_shader(drawing_surface, noone, true, BLEND.alpha);
|
surface_set_shader(drawing_surface, noone, true, BLEND.alpha);
|
||||||
canvas_draw_line_size(brush, mouse_pre_draw_x, mouse_pre_draw_y, mouse_cur_x, mouse_cur_y, true);
|
canvas_draw_line_brush(brush, mouse_pre_draw_x, mouse_pre_draw_y, mouse_cur_x, mouse_cur_y, true);
|
||||||
surface_reset_shader();
|
surface_reset_shader();
|
||||||
mouse_holding = false;
|
mouse_holding = false;
|
||||||
|
|
||||||
|
@ -55,8 +61,8 @@ function canvas_tool_brush(brush, eraser = false) : canvas_tool() constructor {
|
||||||
|
|
||||||
if(_move || !_1stp) {
|
if(_move || !_1stp) {
|
||||||
surface_set_shader(drawing_surface, noone, false, BLEND.alpha);
|
surface_set_shader(drawing_surface, noone, false, BLEND.alpha);
|
||||||
if(_1stp) canvas_draw_point_size(brush, mouse_cur_x, mouse_cur_y, true);
|
if(_1stp) canvas_draw_point_brush(brush, mouse_cur_x, mouse_cur_y, true);
|
||||||
canvas_draw_line_size(brush, mouse_pre_draw_x, mouse_pre_draw_y, mouse_cur_x, mouse_cur_y, true);
|
canvas_draw_line_brush(brush, mouse_pre_draw_x, mouse_pre_draw_y, mouse_cur_x, mouse_cur_y, true);
|
||||||
surface_reset_shader();
|
surface_reset_shader();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -79,9 +85,42 @@ function canvas_tool_brush(brush, eraser = false) : canvas_tool() constructor {
|
||||||
function drawPreview(hover, active, _x, _y, _s, _mx, _my, _snx, _sny) {
|
function drawPreview(hover, active, _x, _y, _s, _mx, _my, _snx, _sny) {
|
||||||
if(isEraser) draw_set_color(c_white);
|
if(isEraser) draw_set_color(c_white);
|
||||||
|
|
||||||
if(mouse_pre_draw_x != undefined && mouse_pre_draw_y != undefined && key_mod_press(SHIFT))
|
mouse_line_drawing = false;
|
||||||
canvas_draw_line_size(brush, mouse_pre_draw_x, mouse_pre_draw_y, mouse_cur_x, mouse_cur_y);
|
|
||||||
else
|
if(mouse_pre_draw_x != undefined && mouse_pre_draw_y != undefined && key_mod_press(SHIFT)) {
|
||||||
canvas_draw_point_size(brush, mouse_cur_x, mouse_cur_y);
|
|
||||||
|
canvas_draw_line_brush(brush, mouse_pre_draw_x, mouse_pre_draw_y, mouse_cur_x, mouse_cur_y);
|
||||||
|
mouse_line_drawing = true;
|
||||||
|
mouse_line_x0 = min(mouse_cur_x, mouse_pre_draw_x);
|
||||||
|
mouse_line_y0 = min(mouse_cur_y, mouse_pre_draw_y);
|
||||||
|
mouse_line_x1 = max(mouse_cur_x, mouse_pre_draw_x) + 1;
|
||||||
|
mouse_line_y1 = max(mouse_cur_y, mouse_pre_draw_y) + 1;
|
||||||
|
|
||||||
|
} else
|
||||||
|
canvas_draw_point_brush(brush, mouse_cur_x, mouse_cur_y);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function drawPostOverlay(hover, active, _x, _y, _s, _mx, _my, _snx, _sny) {
|
||||||
|
|
||||||
|
if(mouse_line_drawing && !brush.brush_sizing && node.attributes.show_slope_check) {
|
||||||
|
var _x0 = _x + mouse_line_x0 * _s;
|
||||||
|
var _y0 = _y + mouse_line_y0 * _s;
|
||||||
|
var _x1 = _x + mouse_line_x1 * _s;
|
||||||
|
var _y1 = _y + mouse_line_y1 * _s;
|
||||||
|
|
||||||
|
var _w = mouse_line_x1 - mouse_line_x0;
|
||||||
|
var _h = mouse_line_y1 - mouse_line_y0;
|
||||||
|
var _as = max(_w, _h) % min(_w, _h) == 0;
|
||||||
|
|
||||||
|
draw_set_color(_as? COLORS._main_value_positive : COLORS._main_accent);
|
||||||
|
draw_rectangle(_x0, _y0, _x1, _y1, true);
|
||||||
|
|
||||||
|
draw_set_text(f_p3, fa_center, fa_top);
|
||||||
|
draw_text((_x0 + _x1) / 2, _y1 + 8, _w);
|
||||||
|
|
||||||
|
draw_set_text(f_p3, fa_left, fa_center);
|
||||||
|
draw_text(_x1 + 8, (_y0 + _y1) / 2, _h);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -1,4 +1,4 @@
|
||||||
// 2024-04-14 14:45:30
|
// 2024-04-18 15:43:04
|
||||||
function canvas_tool_brush(brush, eraser = false) : canvas_tool() constructor {
|
function canvas_tool_brush(brush, eraser = false) : canvas_tool() constructor {
|
||||||
self.brush = brush;
|
self.brush = brush;
|
||||||
isEraser = eraser;
|
isEraser = eraser;
|
||||||
|
@ -12,6 +12,12 @@ function canvas_tool_brush(brush, eraser = false) : canvas_tool() constructor {
|
||||||
mouse_pre_draw_x = undefined;
|
mouse_pre_draw_x = undefined;
|
||||||
mouse_pre_draw_y = undefined;
|
mouse_pre_draw_y = undefined;
|
||||||
|
|
||||||
|
mouse_line_drawing = false;
|
||||||
|
mouse_line_x0 = 0;
|
||||||
|
mouse_line_y0 = 0;
|
||||||
|
mouse_line_x1 = 0;
|
||||||
|
mouse_line_y1 = 0;
|
||||||
|
|
||||||
function step(hover, active, _x, _y, _s, _mx, _my, _snx, _sny) {
|
function step(hover, active, _x, _y, _s, _mx, _my, _snx, _sny) {
|
||||||
|
|
||||||
mouse_cur_x = round((_mx - _x) / _s - 0.5);
|
mouse_cur_x = round((_mx - _x) / _s - 0.5);
|
||||||
|
@ -28,17 +34,15 @@ function canvas_tool_brush(brush, eraser = false) : canvas_tool() constructor {
|
||||||
}
|
}
|
||||||
|
|
||||||
if(mouse_press(mb_left, active)) {
|
if(mouse_press(mb_left, active)) {
|
||||||
brush_next_dist = 0;
|
|
||||||
|
|
||||||
surface_set_shader(drawing_surface, noone);
|
surface_set_shader(drawing_surface, noone);
|
||||||
canvas_draw_point_size(brush, mouse_cur_x, mouse_cur_y, true);
|
canvas_draw_point_brush(brush, mouse_cur_x, mouse_cur_y, true);
|
||||||
surface_reset_shader();
|
surface_reset_shader();
|
||||||
|
|
||||||
mouse_holding = true;
|
mouse_holding = true;
|
||||||
if(mouse_pre_draw_x != undefined && mouse_pre_draw_y != undefined && key_mod_press(SHIFT)) { ///////////////// shift line
|
if(mouse_pre_draw_x != undefined && mouse_pre_draw_y != undefined && key_mod_press(SHIFT)) { ///////////////// shift line
|
||||||
surface_set_shader(drawing_surface, noone, true, BLEND.alpha);
|
surface_set_shader(drawing_surface, noone, true, BLEND.alpha);
|
||||||
brush_next_dist = 0;
|
canvas_draw_line_brush(brush, mouse_pre_draw_x, mouse_pre_draw_y, mouse_cur_x, mouse_cur_y, true);
|
||||||
canvas_draw_line_size(brush, mouse_pre_draw_x, mouse_pre_draw_y, mouse_cur_x, mouse_cur_y, true);
|
|
||||||
surface_reset_shader();
|
surface_reset_shader();
|
||||||
mouse_holding = false;
|
mouse_holding = false;
|
||||||
|
|
||||||
|
@ -57,8 +61,8 @@ function canvas_tool_brush(brush, eraser = false) : canvas_tool() constructor {
|
||||||
|
|
||||||
if(_move || !_1stp) {
|
if(_move || !_1stp) {
|
||||||
surface_set_shader(drawing_surface, noone, false, BLEND.alpha);
|
surface_set_shader(drawing_surface, noone, false, BLEND.alpha);
|
||||||
if(_1stp) canvas_draw_point_size(brush, mouse_cur_x, mouse_cur_y, true);
|
if(_1stp) canvas_draw_point_brush(brush, mouse_cur_x, mouse_cur_y, true);
|
||||||
canvas_draw_line_size(brush, mouse_pre_draw_x, mouse_pre_draw_y, mouse_cur_x, mouse_cur_y, true);
|
canvas_draw_line_brush(brush, mouse_pre_draw_x, mouse_pre_draw_y, mouse_cur_x, mouse_cur_y, true);
|
||||||
surface_reset_shader();
|
surface_reset_shader();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -81,9 +85,42 @@ function canvas_tool_brush(brush, eraser = false) : canvas_tool() constructor {
|
||||||
function drawPreview(hover, active, _x, _y, _s, _mx, _my, _snx, _sny) {
|
function drawPreview(hover, active, _x, _y, _s, _mx, _my, _snx, _sny) {
|
||||||
if(isEraser) draw_set_color(c_white);
|
if(isEraser) draw_set_color(c_white);
|
||||||
|
|
||||||
if(mouse_pre_draw_x != undefined && mouse_pre_draw_y != undefined && key_mod_press(SHIFT))
|
mouse_line_drawing = false;
|
||||||
canvas_draw_line_size(brush, mouse_pre_draw_x, mouse_pre_draw_y, mouse_cur_x, mouse_cur_y);
|
|
||||||
else
|
if(mouse_pre_draw_x != undefined && mouse_pre_draw_y != undefined && key_mod_press(SHIFT)) {
|
||||||
canvas_draw_point_size(brush, mouse_cur_x, mouse_cur_y);
|
|
||||||
|
canvas_draw_line_brush(brush, mouse_pre_draw_x, mouse_pre_draw_y, mouse_cur_x, mouse_cur_y);
|
||||||
|
mouse_line_drawing = true;
|
||||||
|
mouse_line_x0 = min(mouse_cur_x, mouse_pre_draw_x);
|
||||||
|
mouse_line_y0 = min(mouse_cur_y, mouse_pre_draw_y);
|
||||||
|
mouse_line_x1 = max(mouse_cur_x, mouse_pre_draw_x) + 1;
|
||||||
|
mouse_line_y1 = max(mouse_cur_y, mouse_pre_draw_y) + 1;
|
||||||
|
|
||||||
|
} else
|
||||||
|
canvas_draw_point_brush(brush, mouse_cur_x, mouse_cur_y);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function drawPostOverlay(hover, active, _x, _y, _s, _mx, _my, _snx, _sny) {
|
||||||
|
|
||||||
|
if(mouse_line_drawing && !brush.brush_sizing) {
|
||||||
|
var _x0 = _x + mouse_line_x0 * _s;
|
||||||
|
var _y0 = _y + mouse_line_y0 * _s;
|
||||||
|
var _x1 = _x + mouse_line_x1 * _s;
|
||||||
|
var _y1 = _y + mouse_line_y1 * _s;
|
||||||
|
|
||||||
|
var _w = mouse_line_x1 - mouse_line_x0;
|
||||||
|
var _h = mouse_line_y1 - mouse_line_y0;
|
||||||
|
var _as = max(_w, _h) % min(_w, _h) == 0;
|
||||||
|
|
||||||
|
draw_set_color(_as? COLORS._main_value_positive : COLORS._main_accent);
|
||||||
|
draw_rectangle(_x0, _y0, _x1, _y1, true);
|
||||||
|
|
||||||
|
draw_set_text(f_p3, fa_center, fa_top);
|
||||||
|
draw_text((_x0 + _x1) / 2, _y1 + 8, _w);
|
||||||
|
|
||||||
|
draw_set_text(f_p3, fa_left, fa_center);
|
||||||
|
draw_text(_x1 + 8, (_y0 + _y1) / 2, _h);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -1,4 +1,4 @@
|
||||||
// 2024-04-18 15:00:59
|
// 2024-04-18 16:15:18
|
||||||
function Node_Canvas(_x, _y, _group = noone) : Node(_x, _y, _group) constructor {
|
function Node_Canvas(_x, _y, _group = noone) : Node(_x, _y, _group) constructor {
|
||||||
name = "Canvas";
|
name = "Canvas";
|
||||||
color = COLORS.node_blend_canvas;
|
color = COLORS.node_blend_canvas;
|
||||||
|
@ -184,6 +184,9 @@ function Node_Canvas(_x, _y, _group = noone) : Node(_x, _y, _group) constructor
|
||||||
|
|
||||||
draw_stack = ds_list_create();
|
draw_stack = ds_list_create();
|
||||||
|
|
||||||
|
attributes.show_slope_check = true;
|
||||||
|
array_push(attributeEditors, "Display");
|
||||||
|
array_push(attributeEditors, [ "Slope Check", function() { return attributes.show_slope_check; }, new checkBox(function() { attributes.show_slope_check = !attributes.show_slope_check; }) ]);
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region ++++ tool object ++++
|
#region ++++ tool object ++++
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
// 2024-04-18 15:00:58
|
// 2024-04-18 16:15:08
|
||||||
function Node_Canvas(_x, _y, _group = noone) : Node(_x, _y, _group) constructor {
|
function Node_Canvas(_x, _y, _group = noone) : Node(_x, _y, _group) constructor {
|
||||||
name = "Canvas";
|
name = "Canvas";
|
||||||
color = COLORS.node_blend_canvas;
|
color = COLORS.node_blend_canvas;
|
||||||
|
@ -184,6 +184,9 @@ function Node_Canvas(_x, _y, _group = noone) : Node(_x, _y, _group) constructor
|
||||||
|
|
||||||
draw_stack = ds_list_create();
|
draw_stack = ds_list_create();
|
||||||
|
|
||||||
|
attributes.show_slope_check = true;
|
||||||
|
array_push(attributeEditors, "Display");
|
||||||
|
array_push(attributeEditors, [ "Slope Check", function() { return attributes.show_slope_check; }, new checkBox(function() { attributes.show_slope_check = !attributes.show_slope_check; }) ]);
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region ++++ tool object ++++
|
#region ++++ tool object ++++
|
||||||
|
|
|
@ -11,6 +11,12 @@ function canvas_tool_brush(brush, eraser = false) : canvas_tool() constructor {
|
||||||
mouse_pre_draw_x = undefined;
|
mouse_pre_draw_x = undefined;
|
||||||
mouse_pre_draw_y = undefined;
|
mouse_pre_draw_y = undefined;
|
||||||
|
|
||||||
|
mouse_line_drawing = false;
|
||||||
|
mouse_line_x0 = 0;
|
||||||
|
mouse_line_y0 = 0;
|
||||||
|
mouse_line_x1 = 0;
|
||||||
|
mouse_line_y1 = 0;
|
||||||
|
|
||||||
function step(hover, active, _x, _y, _s, _mx, _my, _snx, _sny) {
|
function step(hover, active, _x, _y, _s, _mx, _my, _snx, _sny) {
|
||||||
|
|
||||||
mouse_cur_x = round((_mx - _x) / _s - 0.5);
|
mouse_cur_x = round((_mx - _x) / _s - 0.5);
|
||||||
|
@ -78,9 +84,42 @@ function canvas_tool_brush(brush, eraser = false) : canvas_tool() constructor {
|
||||||
function drawPreview(hover, active, _x, _y, _s, _mx, _my, _snx, _sny) {
|
function drawPreview(hover, active, _x, _y, _s, _mx, _my, _snx, _sny) {
|
||||||
if(isEraser) draw_set_color(c_white);
|
if(isEraser) draw_set_color(c_white);
|
||||||
|
|
||||||
if(mouse_pre_draw_x != undefined && mouse_pre_draw_y != undefined && key_mod_press(SHIFT))
|
mouse_line_drawing = false;
|
||||||
|
|
||||||
|
if(mouse_pre_draw_x != undefined && mouse_pre_draw_y != undefined && key_mod_press(SHIFT)) {
|
||||||
|
|
||||||
canvas_draw_line_brush(brush, mouse_pre_draw_x, mouse_pre_draw_y, mouse_cur_x, mouse_cur_y);
|
canvas_draw_line_brush(brush, mouse_pre_draw_x, mouse_pre_draw_y, mouse_cur_x, mouse_cur_y);
|
||||||
else
|
mouse_line_drawing = true;
|
||||||
|
mouse_line_x0 = min(mouse_cur_x, mouse_pre_draw_x);
|
||||||
|
mouse_line_y0 = min(mouse_cur_y, mouse_pre_draw_y);
|
||||||
|
mouse_line_x1 = max(mouse_cur_x, mouse_pre_draw_x) + 1;
|
||||||
|
mouse_line_y1 = max(mouse_cur_y, mouse_pre_draw_y) + 1;
|
||||||
|
|
||||||
|
} else
|
||||||
canvas_draw_point_brush(brush, mouse_cur_x, mouse_cur_y);
|
canvas_draw_point_brush(brush, mouse_cur_x, mouse_cur_y);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function drawPostOverlay(hover, active, _x, _y, _s, _mx, _my, _snx, _sny) {
|
||||||
|
|
||||||
|
if(mouse_line_drawing && !brush.brush_sizing && node.attributes.show_slope_check) {
|
||||||
|
var _x0 = _x + mouse_line_x0 * _s;
|
||||||
|
var _y0 = _y + mouse_line_y0 * _s;
|
||||||
|
var _x1 = _x + mouse_line_x1 * _s;
|
||||||
|
var _y1 = _y + mouse_line_y1 * _s;
|
||||||
|
|
||||||
|
var _w = mouse_line_x1 - mouse_line_x0;
|
||||||
|
var _h = mouse_line_y1 - mouse_line_y0;
|
||||||
|
var _as = max(_w, _h) % min(_w, _h) == 0;
|
||||||
|
|
||||||
|
draw_set_color(_as? COLORS._main_value_positive : COLORS._main_accent);
|
||||||
|
draw_rectangle(_x0, _y0, _x1, _y1, true);
|
||||||
|
|
||||||
|
draw_set_text(f_p3, fa_center, fa_top);
|
||||||
|
draw_text((_x0 + _x1) / 2, _y1 + 8, _w);
|
||||||
|
|
||||||
|
draw_set_text(f_p3, fa_left, fa_center);
|
||||||
|
draw_text(_x1 + 8, (_y0 + _y1) / 2, _h);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -183,6 +183,9 @@ function Node_Canvas(_x, _y, _group = noone) : Node(_x, _y, _group) constructor
|
||||||
|
|
||||||
draw_stack = ds_list_create();
|
draw_stack = ds_list_create();
|
||||||
|
|
||||||
|
attributes.show_slope_check = true;
|
||||||
|
array_push(attributeEditors, "Display");
|
||||||
|
array_push(attributeEditors, [ "Slope Check", function() { return attributes.show_slope_check; }, new checkBox(function() { attributes.show_slope_check = !attributes.show_slope_check; }) ]);
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region ++++ tool object ++++
|
#region ++++ tool object ++++
|
||||||
|
|
Loading…
Reference in a new issue