diff --git a/#backups/scripts/canvas_tool_brush/canvas_tool_brush.gml.backup0 b/#backups/scripts/canvas_tool_brush/canvas_tool_brush.gml.backup0 index 2132dd44b..b5c6477d6 100644 --- a/#backups/scripts/canvas_tool_brush/canvas_tool_brush.gml.backup0 +++ b/#backups/scripts/canvas_tool_brush/canvas_tool_brush.gml.backup0 @@ -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 { self.brush = brush; isEraser = eraser; @@ -12,6 +12,12 @@ function canvas_tool_brush(brush, eraser = false) : canvas_tool() constructor { mouse_pre_draw_x = 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) { 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)) { 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(); mouse_holding = true; 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); - 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(); mouse_holding = false; @@ -55,8 +61,8 @@ function canvas_tool_brush(brush, eraser = false) : canvas_tool() constructor { if(_move || !_1stp) { surface_set_shader(drawing_surface, noone, false, BLEND.alpha); - if(_1stp) canvas_draw_point_size(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); + if(_1stp) canvas_draw_point_brush(brush, 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(); } @@ -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) { if(isEraser) draw_set_color(c_white); - if(mouse_pre_draw_x != undefined && mouse_pre_draw_y != undefined && key_mod_press(SHIFT)) - canvas_draw_line_size(brush, mouse_pre_draw_x, mouse_pre_draw_y, mouse_cur_x, mouse_cur_y); - else - canvas_draw_point_size(brush, mouse_cur_x, mouse_cur_y); + 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); + 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); + } + } + } \ No newline at end of file diff --git a/#backups/scripts/canvas_tool_brush/canvas_tool_brush.gml.backup1 b/#backups/scripts/canvas_tool_brush/canvas_tool_brush.gml.backup1 index 3d2386700..41f74fb69 100644 --- a/#backups/scripts/canvas_tool_brush/canvas_tool_brush.gml.backup1 +++ b/#backups/scripts/canvas_tool_brush/canvas_tool_brush.gml.backup1 @@ -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 { self.brush = brush; isEraser = eraser; @@ -12,6 +12,12 @@ function canvas_tool_brush(brush, eraser = false) : canvas_tool() constructor { mouse_pre_draw_x = 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) { 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)) { - brush_next_dist = 0; 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(); mouse_holding = true; 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); - brush_next_dist = 0; - 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(); mouse_holding = false; @@ -57,8 +61,8 @@ function canvas_tool_brush(brush, eraser = false) : canvas_tool() constructor { if(_move || !_1stp) { surface_set_shader(drawing_surface, noone, false, BLEND.alpha); - if(_1stp) canvas_draw_point_size(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); + if(_1stp) canvas_draw_point_brush(brush, 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(); } @@ -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) { if(isEraser) draw_set_color(c_white); - if(mouse_pre_draw_x != undefined && mouse_pre_draw_y != undefined && key_mod_press(SHIFT)) - canvas_draw_line_size(brush, mouse_pre_draw_x, mouse_pre_draw_y, mouse_cur_x, mouse_cur_y); - else - canvas_draw_point_size(brush, mouse_cur_x, mouse_cur_y); + 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); + 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); + } + } + } \ No newline at end of file diff --git a/#backups/scripts/node_canvas/node_canvas.gml.backup0 b/#backups/scripts/node_canvas/node_canvas.gml.backup0 index 9af37958b..2a796d67d 100644 --- a/#backups/scripts/node_canvas/node_canvas.gml.backup0 +++ b/#backups/scripts/node_canvas/node_canvas.gml.backup0 @@ -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 { name = "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(); + 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 #region ++++ tool object ++++ diff --git a/#backups/scripts/node_canvas/node_canvas.gml.backup1 b/#backups/scripts/node_canvas/node_canvas.gml.backup1 index 356b8182b..58799db9b 100644 --- a/#backups/scripts/node_canvas/node_canvas.gml.backup1 +++ b/#backups/scripts/node_canvas/node_canvas.gml.backup1 @@ -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 { name = "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(); + 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 #region ++++ tool object ++++ diff --git a/scripts/canvas_tool_brush/canvas_tool_brush.gml b/scripts/canvas_tool_brush/canvas_tool_brush.gml index 87667a87f..edb38b065 100644 --- a/scripts/canvas_tool_brush/canvas_tool_brush.gml +++ b/scripts/canvas_tool_brush/canvas_tool_brush.gml @@ -11,6 +11,12 @@ function canvas_tool_brush(brush, eraser = false) : canvas_tool() constructor { mouse_pre_draw_x = 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) { 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) { 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); - 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); } + + 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); + } + } + } \ No newline at end of file diff --git a/scripts/node_canvas/node_canvas.gml b/scripts/node_canvas/node_canvas.gml index e55d2d9df..2c5e6fa5b 100644 --- a/scripts/node_canvas/node_canvas.gml +++ b/scripts/node_canvas/node_canvas.gml @@ -183,6 +183,9 @@ function Node_Canvas(_x, _y, _group = noone) : Node(_x, _y, _group) constructor 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 #region ++++ tool object ++++