canvas cube tool

This commit is contained in:
Tanasart 2024-07-04 18:51:04 +07:00
parent 9a853c813d
commit 2a5bcb6482
18 changed files with 410 additions and 49 deletions

View file

@ -413,6 +413,7 @@
{"name":"canvas_flood_fill_functions","order":2,"path":"scripts/canvas_flood_fill_functions/canvas_flood_fill_functions.yy",}, {"name":"canvas_flood_fill_functions","order":2,"path":"scripts/canvas_flood_fill_functions/canvas_flood_fill_functions.yy",},
{"name":"canvas_freeform","order":3,"path":"scripts/canvas_freeform/canvas_freeform.yy",}, {"name":"canvas_freeform","order":3,"path":"scripts/canvas_freeform/canvas_freeform.yy",},
{"name":"canvas_magic_selection_functions","order":4,"path":"scripts/canvas_magic_selection_functions/canvas_magic_selection_functions.yy",}, {"name":"canvas_magic_selection_functions","order":4,"path":"scripts/canvas_magic_selection_functions/canvas_magic_selection_functions.yy",},
{"name":"canvas_tool_brush_shape_iso","order":15,"path":"scripts/canvas_tool_brush_shape_iso/canvas_tool_brush_shape_iso.yy",},
{"name":"canvas_tool_brush_shape","order":3,"path":"scripts/canvas_tool_brush_shape/canvas_tool_brush_shape.yy",}, {"name":"canvas_tool_brush_shape","order":3,"path":"scripts/canvas_tool_brush_shape/canvas_tool_brush_shape.yy",},
{"name":"canvas_tool_corner","order":7,"path":"scripts/canvas_tool_corner/canvas_tool_corner.yy",}, {"name":"canvas_tool_corner","order":7,"path":"scripts/canvas_tool_corner/canvas_tool_corner.yy",},
{"name":"canvas_tool_curve","order":14,"path":"scripts/canvas_tool_curve/canvas_tool_curve.yy",}, {"name":"canvas_tool_curve","order":14,"path":"scripts/canvas_tool_curve/canvas_tool_curve.yy",},

View file

@ -732,6 +732,7 @@
{"id":{"name":"canvas_flood_fill_functions","path":"scripts/canvas_flood_fill_functions/canvas_flood_fill_functions.yy",},}, {"id":{"name":"canvas_flood_fill_functions","path":"scripts/canvas_flood_fill_functions/canvas_flood_fill_functions.yy",},},
{"id":{"name":"canvas_freeform","path":"scripts/canvas_freeform/canvas_freeform.yy",},}, {"id":{"name":"canvas_freeform","path":"scripts/canvas_freeform/canvas_freeform.yy",},},
{"id":{"name":"canvas_magic_selection_functions","path":"scripts/canvas_magic_selection_functions/canvas_magic_selection_functions.yy",},}, {"id":{"name":"canvas_magic_selection_functions","path":"scripts/canvas_magic_selection_functions/canvas_magic_selection_functions.yy",},},
{"id":{"name":"canvas_tool_brush_shape_iso","path":"scripts/canvas_tool_brush_shape_iso/canvas_tool_brush_shape_iso.yy",},},
{"id":{"name":"canvas_tool_brush_shape","path":"scripts/canvas_tool_brush_shape/canvas_tool_brush_shape.yy",},}, {"id":{"name":"canvas_tool_brush_shape","path":"scripts/canvas_tool_brush_shape/canvas_tool_brush_shape.yy",},},
{"id":{"name":"canvas_tool_brush","path":"scripts/canvas_tool_brush/canvas_tool_brush.yy",},}, {"id":{"name":"canvas_tool_brush","path":"scripts/canvas_tool_brush/canvas_tool_brush.yy",},},
{"id":{"name":"canvas_tool_corner","path":"scripts/canvas_tool_corner/canvas_tool_corner.yy",},}, {"id":{"name":"canvas_tool_corner","path":"scripts/canvas_tool_corner/canvas_tool_corner.yy",},},

Binary file not shown.

View file

@ -228,17 +228,20 @@ event_inherited();
for(var i = 0; i < ds_list_size(_junc_list); i++) { for(var i = 0; i < ds_list_size(_junc_list); i++) {
var _target = _junc_list[| i]; var _target = _junc_list[| i];
if(!_target.visible) continue; if(!_target.auto_connect) continue;
if(_target.auto_connect) { if(_call_input && node_called.isConnectable(_junc_list[| i]) == 1) {
if(_call_input && node_called.isConnectable(_junc_list[| i])) {
node_called.setFrom(_junc_list[| i]); node_called.setFrom(_junc_list[| i]);
_new_node.x -= _new_node.w; _new_node.x -= _new_node.w;
} else if(!_call_input && _junc_list[| i].isConnectable(node_called)) break;
}
if(!_call_input && _junc_list[| i].isConnectable(node_called) == 1) {
_junc_list[| i].setFrom(node_called); _junc_list[| i].setFrom(node_called);
break; break;
} }
} }
} else if(junction_hovering != noone) { //right click on junction } else if(junction_hovering != noone) { //right click on junction
var to = junction_hovering; var to = junction_hovering;
var from = junction_hovering.value_from; var from = junction_hovering.value_from;

View file

@ -2,9 +2,9 @@
"$GMObject":"", "$GMObject":"",
"%Name":"o_dialog_add_node", "%Name":"o_dialog_add_node",
"eventList":[ "eventList":[
{"$GMEvent":"v1","%Name":"","collisionObjectId":null,"eventNum":64,"eventType":8,"isDnD":false,"name":"","resourceType":"GMEvent","resourceVersion":"2.0",}, {"$GMEvent":"","%Name":"","collisionObjectId":null,"eventNum":64,"eventType":8,"isDnD":false,"name":"","resourceType":"GMEvent","resourceVersion":"2.0",},
{"$GMEvent":"v1","%Name":"","collisionObjectId":null,"eventNum":0,"eventType":0,"isDnD":false,"name":"","resourceType":"GMEvent","resourceVersion":"2.0",}, {"$GMEvent":"","%Name":"","collisionObjectId":null,"eventNum":0,"eventType":0,"isDnD":false,"name":"","resourceType":"GMEvent","resourceVersion":"2.0",},
{"$GMEvent":"v1","%Name":"","collisionObjectId":null,"eventNum":0,"eventType":1,"isDnD":false,"name":"","resourceType":"GMEvent","resourceVersion":"2.0",}, {"$GMEvent":"","%Name":"","collisionObjectId":null,"eventNum":0,"eventType":1,"isDnD":false,"name":"","resourceType":"GMEvent","resourceVersion":"2.0",},
], ],
"managed":true, "managed":true,
"name":"o_dialog_add_node", "name":"o_dialog_add_node",

View file

@ -21,6 +21,8 @@ function canvas_brush() constructor {
node = noone; node = noone;
colors = [ c_white, c_black ];
function step(hover, active, _x, _y, _s, _mx, _my, _snx, _sny) { function step(hover, active, _x, _y, _s, _mx, _my, _snx, _sny) {
var _brushSurf = node.getInputData(6); var _brushSurf = node.getInputData(6);

View file

@ -14,6 +14,8 @@ function canvas_tool() constructor {
brush_resizable = false; brush_resizable = false;
mouse_holding = false; mouse_holding = false;
use_color_3d = false;
subtool = 0; subtool = 0;
function disable() { function disable() {

View file

@ -24,15 +24,38 @@ function canvas_draw_point_brush(brush, _x, _y, _draw = false) { #region
} }
} #endregion } #endregion
function canvas_draw_line(_x0, _y0, _x1, _y1, _th = 1) {
if(_th < global.FIX_POINTS_AMOUNT) {
if(_x1 > _x0) _x0--;
if(_x1 < _x0) _x1--;
if(_y1 > _y0) _y0--;
if(_y1 < _y0) _y1--;
}
if(_th == 1) {
draw_line(_x0, _y0, _x1, _y1);
} else if(_th < global.FIX_POINTS_AMOUNT) {
var fx = global.FIX_POINTS[_th];
for( var i = 0, n = array_length(fx); i < n; i++ )
draw_line(_x0 + fx[i][0], _y0 + fx[i][1], _x1 + fx[i][0], _y1 + fx[i][1]);
} else
draw_line_width(_x0, _y0, _x1, _y1, _th);
}
function canvas_draw_line_brush(brush, _x0, _y0, _x1, _y1, _draw = false, _cap = false) { #region function canvas_draw_line_brush(brush, _x0, _y0, _x1, _y1, _draw = false, _cap = false) { #region
if(brush.brush_surface == noone) { if(brush.brush_surface == noone) {
if(brush.brush_size < global.FIX_POINTS_AMOUNT) { if(brush.brush_size < global.FIX_POINTS_AMOUNT) {
if(_x1 > _x0) _x0--; if(_x1 > _x0) _x0--;
if(_x1 < _x0) _x1--;
if(_y1 > _y0) _y0--; if(_y1 > _y0) _y0--;
if(_y1 < _y0) _y1--; if(_y1 < _y0) _y1--;
if(_x1 < _x0) _x1--;
} }
if(brush.brush_size == 1) { if(brush.brush_size == 1) {
@ -205,3 +228,5 @@ function canvas_draw_curve_brush(brush, x0, y0, cx0, cy0, cx1, cy1, x1, y1, prec
oy = ny; oy = ny;
} }
} #endregion } #endregion
function canvas_draw_triangle(x1, y1, x2, y2, x3, y3, outline = false) { INLINE draw_triangle(round(x1), round(y1), round(x2), round(y2), round(x3), round(y3), outline); }

View file

@ -32,13 +32,10 @@ function canvas_tool_shape(brush, shape) : canvas_tool() constructor {
if(mouse_holding) { if(mouse_holding) {
surface_set_shader(drawing_surface, noone); surface_set_shader(drawing_surface, noone);
switch(shape) {
if(shape == CANVAS_TOOL_SHAPE.rectangle) case CANVAS_TOOL_SHAPE.rectangle : canvas_draw_rect_brush(brush, mouse_pre_x, mouse_pre_y, mouse_cur_x, mouse_cur_y, subtool); break;
canvas_draw_rect_brush(brush, mouse_pre_x, mouse_pre_y, mouse_cur_x, mouse_cur_y, subtool); case CANVAS_TOOL_SHAPE.ellipse : canvas_draw_ellp_brush(brush, mouse_pre_x, mouse_pre_y, mouse_cur_x, mouse_cur_y, subtool); break;
}
else if(shape == CANVAS_TOOL_SHAPE.ellipse)
canvas_draw_ellp_brush(brush, mouse_pre_x, mouse_pre_y, mouse_cur_x, mouse_cur_y, subtool);
surface_reset_shader(); surface_reset_shader();
if(mouse_release(mb_left)) { if(mouse_release(mb_left)) {
@ -64,11 +61,10 @@ function canvas_tool_shape(brush, shape) : canvas_tool() constructor {
return; return;
} }
if(shape == CANVAS_TOOL_SHAPE.rectangle) switch(shape) {
canvas_draw_rect_brush(brush, mouse_pre_x, mouse_pre_y, mouse_cur_x, mouse_cur_y, subtool); case CANVAS_TOOL_SHAPE.rectangle : canvas_draw_rect_brush(brush, mouse_pre_x, mouse_pre_y, mouse_cur_x, mouse_cur_y, subtool); break;
case CANVAS_TOOL_SHAPE.ellipse : canvas_draw_ellp_brush(brush, mouse_pre_x, mouse_pre_y, mouse_cur_x, mouse_cur_y, subtool); break;
if(shape == CANVAS_TOOL_SHAPE.ellipse) }
canvas_draw_ellp_brush(brush, mouse_pre_x, mouse_pre_y, mouse_cur_x, mouse_cur_y, subtool);
} }
function drawPostOverlay(hover, active, _x, _y, _s, _mx, _my, _snx, _sny) { function drawPostOverlay(hover, active, _x, _y, _s, _mx, _my, _snx, _sny) {

View file

@ -0,0 +1,267 @@
enum CANVAS_TOOL_SHAPE_ISO {
cube,
}
function canvas_tool_shape_iso(brush, shape) : canvas_tool() constructor {
self.brush = brush;
self.shape = shape;
use_color_3d = true;
brush_resizable = true;
mouse_holding = 0;
mouse_cur_x = 0;
mouse_cur_y = 0;
mouse_points = [ [ 0, 0 ], [ 0, 0 ], 0 ];
function init() {
mouse_points = [ [ 0, 0 ], [ 0, 0 ], 0 ];
}
function step(hover, active, _x, _y, _s, _mx, _my, _snx, _sny) {
mouse_cur_x = round((_mx - _x) / _s - 0.5);
mouse_cur_y = round((_my - _y) / _s - 0.5);
if(mouse_holding) {
surface_set_shader(drawing_surface, noone);
canvas_draw_iso_cube(brush, mouse_points, subtool);
surface_reset_shader();
}
switch(mouse_holding) {
case 0 :
mouse_points[0][0] = mouse_cur_x;
mouse_points[0][1] = mouse_cur_y;
if(mouse_press(mb_left, active)) {
mouse_points[0][0] = mouse_cur_x;
mouse_points[0][1] = mouse_cur_y;
mouse_points[1][0] = mouse_cur_x;
mouse_points[1][1] = mouse_cur_y;
mouse_points[2] = 0;
node.tool_pick_color(mouse_cur_x, mouse_cur_y);
mouse_holding = 1;
}
break;
case 1 :
mouse_points[1][0] = mouse_cur_x;
mouse_points[1][1] = mouse_cur_y;
if(mouse_release(mb_left))
mouse_holding = 2;
break;
case 2 :
mouse_points[2] = mouse_cur_y - mouse_points[1][1];
if(mouse_press(mb_left, active)) {
apply_draw_surface();
mouse_holding = 0;
}
break;
}
if(mouse_press(mb_right, active))
mouse_holding = 0;
}
function drawPreview(hover, active, _x, _y, _s, _mx, _my, _snx, _sny) {
if(mouse_holding == 0) { canvas_draw_point_brush(brush, mouse_cur_x, mouse_cur_y); return; }
}
function drawPostOverlay(hover, active, _x, _y, _s, _mx, _my, _snx, _sny) {
if(mouse_holding == 0) return;
if(brush.brush_sizing) return;
if(!node.attributes.show_slope_check) return;
}
}
function canvas_draw_iso_cube(brush, _p, _fill = false) {
var p0x = _p[0][0], p0y = _p[0][1];
var p1x = _p[1][0], p1y = _p[1][1];
if(p1x < p0x) {
var tx = p0x, ty = p0y;
p0x = p1x; p0y = p1y;
p1x = tx; p1y = ty;
}
var d = _p[2];
var w = p1x - p0x + 1;
var h = p0y - p1y;
var h2 = (w + 2 * h) / 4;
var h1 = h2 - h;
var w1 = h1 * 2;
var p0px = p0x + w1;
var p0py = p0y + h1;
var p1px = p1x - w1;
var p1py = p1y - h1;
var _simp = true;
if(w > 0) {
if(round(h2) < 0) {
if(round(w1) > 0) {
if(p1px < p0px) {
p0x = floor(p1px);
p0y = floor(p1py);
p1x = ceil(p0px) + 1;
p1y = ceil(p0py);
} else {
p0x = floor(p0px);
p0y = floor(p0py);
p1x = ceil(p1px) + 1;
p1y = ceil(p1py);
}
_simp = false;
}
} else if(round(h2) > 0) {
if(round(w1) < 0) {
if(p1px < p0px) {
p0x = floor(p1px);
p0y = floor(p1py);
p1x = ceil(p0px) + 1;
p1y = ceil(p0py);
} else {
p0x = floor(p0px);
p0y = floor(p0py);
p1x = ceil(p1px) + 1;
p1y = ceil(p1py);
}
_simp = false;
} else if(round(w1) > 0) {
_simp = false;
}
}
}
if(_simp) {
if(_fill == 2) {
if(d == 0) {
canvas_draw_line(p0x, p0y, p1x, p1y);
} else {
canvas_draw_triangle(p0x, p0y, p1x, p1y, p1x, p1y + d, false);
canvas_draw_triangle(p0x, p0y, p0x, p0y + d, p1x, p1y + d, false);
}
} else {
canvas_draw_line_brush(brush, p0x, p0y, p1x, p1y);
if(d != 0) {
canvas_draw_line_brush(brush, p0x, p0y + d, p1x, p1y + d);
canvas_draw_line_brush(brush, p0x, p0y, p0x, p0y + d);
canvas_draw_line_brush(brush, p1x, p1y, p1x, p1y + d);
}
}
} else {
var w = p1x - p0x + 1;
var h = p0y - p1y;
var h2 = (w + 2 * h) / 4;
var h1 = h2 - h;
var w1 = h1 * 2;
var p0px = p0x + w1;
var p0py = p0y + h1;
var p1px = p1x - w1;
var p1py = p1y - h1;
p0py -= (abs(w) > 4);
p1py += (abs(w) > 4);
if(d > 0) {
p0y += d;
p1y += d;
p0py += d;
p1py += d;
d = -d;
}
if(_fill == 2) {
if(d == 0) {
canvas_draw_line(p0x, p0y, p0px - 1, p0py);
canvas_draw_line(p0px, p0py, p1x, p1y);
canvas_draw_line(p1x, p1y, p1px + 1, p1py);
canvas_draw_line(p1px, p1py, p0x, p0y);
canvas_draw_triangle(p0x, p0y, p0px - 1, p0py, p1x - 1, p1y, false);
canvas_draw_triangle(p1x - 1, p1y, p1px, p1py - 1, p0x, p0y, false);
} else {
var cc = draw_get_color();
draw_set_color(brush.colors[1]);
canvas_draw_triangle(p0px, p0py - 1, p1x, p1y + d, p1x, p1y, false);
canvas_draw_triangle(p0px, p0py - 1, p1x, p1y + d, p0px, p0py + d, false);
canvas_draw_line(p0px, p0py + 1 + d, p1x, p1y + 1 + d);
canvas_draw_line(p0px, p0py, p1x, p1y);
canvas_draw_line(p0px, p0py - 1, p0px, p0py + d);
if(d < -1) canvas_draw_line(p0px, p0py - 1, p1x, p1y - 1);
draw_set_color(brush.colors[0]);
canvas_draw_triangle(p0px - 1, p0py, p0x, p0y + d, p0x, p0y, false);
canvas_draw_triangle(p0px - 1, p0py, p0x, p0y + d, p0px - 1, p0py - 1 + d, false);
canvas_draw_line(p0x, p0y + d, p0px - 1, p0py + d);
canvas_draw_line(p0x, p0y, p0px - 1, p0py);
canvas_draw_line(p0x, p0y, p0x, p0y + d);
canvas_draw_line(p0px - 1, p0py, p0px - 1, p0py + d);
draw_set_color(cc);
canvas_draw_triangle(p0x, p0y + d, p0px - 1, p0py + d, p1x - 1, p1y + d, false);
canvas_draw_triangle(p1x - 1, p1y + d, p1px, p1py + d - 1, p0x, p0y + d, false);
canvas_draw_line(p0x, p0y + d, p0px - 1, p0py + d);
canvas_draw_line(p0px, p0py + d, p1x, p1y + d);
canvas_draw_line(p1x, p1y + d, p1px + 1, p1py + d);
canvas_draw_line(p1px, p1py + d, p0x, p0y + d);
}
} else {
canvas_draw_line_brush(brush, p0x, p0y, p0px - 1, p0py);
canvas_draw_line_brush(brush, p0px, p0py, p1x, p1y);
if(_fill == 1) {
canvas_draw_line_brush(brush, p1x, p1y, p1px + 1, p1py);
canvas_draw_line_brush(brush, p1px, p1py, p0x, p0y);
}
if(d != 0) {
canvas_draw_line_brush(brush, p0x, p0y + d, p0px - 1, p0py + d);
canvas_draw_line_brush(brush, p0px, p0py + d, p1x, p1y + d);
canvas_draw_line_brush(brush, p1x, p1y + d, p1px + 1, p1py + d);
canvas_draw_line_brush(brush, p1px, p1py + d, p0x, p0y + d);
canvas_draw_line_brush(brush, p0x, p0y, p0x, p0y + d);
canvas_draw_line_brush(brush, p1x, p1y, p1x, p1y + d);
canvas_draw_line_brush(brush, p0px - 1, p0py, p0px - 1, p0py + d);
if(_fill == 1)
canvas_draw_line_brush(brush, p1px, p1py, p1px, p1py + d);
} else if(_fill == 0) {
canvas_draw_line_brush(brush, p1x, p1y, p1px + 1, p1py);
canvas_draw_line_brush(brush, p1px, p1py, p0x, p0y);
}
}
}
}

View file

@ -0,0 +1,13 @@
{
"$GMScript":"",
"%Name":"canvas_tool_brush_shape_iso",
"isCompatibility":false,
"isDnD":false,
"name":"canvas_tool_brush_shape_iso",
"parent":{
"name":"tools",
"path":"folders/nodes/data/canvas/tools.yy",
},
"resourceType":"GMScript",
"resourceVersion":"2.0",
}

View file

@ -38,7 +38,7 @@
LATEST_VERSION = 11700; LATEST_VERSION = 11700;
VERSION = 11760; VERSION = 11760;
SAVE_VERSION = 11700; SAVE_VERSION = 11700;
VERSION_STRING = "1.17.6.006"; VERSION_STRING = "1.17.6.007";
BUILD_NUMBER = 11760; BUILD_NUMBER = 11760;
globalvar HOTKEYS, HOTKEY_CONTEXT; globalvar HOTKEYS, HOTKEY_CONTEXT;

View file

@ -216,6 +216,8 @@ function Node_Canvas(_x, _y, _group = noone) : Node(_x, _y, _group) constructor
tool_eraser = new canvas_tool_brush(brush, true); tool_eraser = new canvas_tool_brush(brush, true);
tool_rectangle = new canvas_tool_shape(brush, CANVAS_TOOL_SHAPE.rectangle); tool_rectangle = new canvas_tool_shape(brush, CANVAS_TOOL_SHAPE.rectangle);
tool_ellipse = new canvas_tool_shape(brush, CANVAS_TOOL_SHAPE.ellipse); tool_ellipse = new canvas_tool_shape(brush, CANVAS_TOOL_SHAPE.ellipse);
tool_iso_cube = new canvas_tool_shape_iso(brush, CANVAS_TOOL_SHAPE_ISO.cube);
tool_fill = new canvas_tool_fill(tool_attribute); tool_fill = new canvas_tool_fill(tool_attribute);
tool_freeform = new canvas_tool_draw_freeform(brush); tool_freeform = new canvas_tool_draw_freeform(brush);
tool_curve_bez = new canvas_tool_curve_bezier(brush); tool_curve_bez = new canvas_tool_curve_bezier(brush);
@ -226,6 +228,8 @@ function Node_Canvas(_x, _y, _group = noone) : Node(_x, _y, _group) constructor
tool_sel_magic = new canvas_tool_selection_magic(tool_selection, tool_attribute); tool_sel_magic = new canvas_tool_selection_magic(tool_selection, tool_attribute);
tool_sel_brush = new canvas_tool_selection_brush(tool_selection, brush); tool_sel_brush = new canvas_tool_selection_brush(tool_selection, brush);
use_color_3d = false;
color_3d_selected = 0;
#endregion #endregion
#region ++++ tools ++++ #region ++++ tools ++++
@ -298,6 +302,10 @@ function Node_Canvas(_x, _y, _group = noone) : Node(_x, _y, _group) constructor
.setSetting(tool_size) .setSetting(tool_size)
.setToolObject(tool_ellipse), .setToolObject(tool_ellipse),
new NodeTool( "Iso Cube", [ THEME.canvas_tools_iso_cube, THEME.canvas_tools_iso_cube_wire, THEME.canvas_tools_iso_cube_fill ])
.setSetting(tool_size)
.setToolObject(tool_iso_cube),
new NodeTool( "Curve", THEME.canvas_tool_curve_icon) new NodeTool( "Curve", THEME.canvas_tool_curve_icon)
.setSetting(tool_size) .setSetting(tool_size)
.setSetting([ "", tool_curve_apply, 0, tool_attribute ]) .setSetting([ "", tool_curve_apply, 0, tool_attribute ])
@ -399,7 +407,10 @@ function Node_Canvas(_x, _y, _group = noone) : Node(_x, _y, _group) constructor
else preview_index = frame; else preview_index = frame;
} }
function setToolColor(color) { CURRENT_COLOR = color; } function setToolColor(color) {
if(!use_color_3d || color_3d_selected == 0) CURRENT_COLOR = color;
else brush.colors[color_3d_selected - 1] = color;
}
static drawTools = function(_mx, _my, xx, yy, tool_size, hover, focus) { #region static drawTools = function(_mx, _my, xx, yy, tool_size, hover, focus) { #region
var _sx0 = xx - tool_size / 2; var _sx0 = xx - tool_size / 2;
@ -415,18 +426,51 @@ function Node_Canvas(_x, _y, _group = noone) : Node(_x, _y, _group) constructor
var _cw = tool_size - ui(16); var _cw = tool_size - ui(16);
var _ch = ui(12); var _ch = ui(12);
var _pd = ui(5); var _pd = ui(5);
var _currc = CURRENT_COLOR;
yy += ui(8); yy += ui(8);
hh += ui(8); hh += ui(8);
if(use_color_3d) {
var _3x = _cx + _cw / 2;
var _3y = yy + _cw / 2;
draw_sprite_ext(THEME.color_3d, 0, _3x, _3y, 1, 1, 0, CURRENT_COLOR );
draw_sprite_ext(THEME.color_3d, 1, _3x, _3y, 1, 1, 0, brush.colors[0]);
draw_sprite_ext(THEME.color_3d, 2, _3x, _3y, 1, 1, 0, brush.colors[1]);
draw_sprite_ext(THEME.color_3d_selected, color_3d_selected, _3x, _3y);
if(color_3d_selected) _currc = brush.colors[color_3d_selected - 1];
if(point_in_circle(_mx, _my, _3x, _3y, ui(16))) {
var dir = point_direction(_3x, _3y, _mx, _my);
var sel = 0;
if(dir > 150 && dir < 270) sel = 1;
else if(dir > 270 || dir < 30) sel = 2;
if(mouse_press(mb_left, focus)) {
if(color_3d_selected == sel) colorSelectorCall(sel == 0? CURRENT_COLOR : brush.colors[sel - 1], setToolColor);
else color_3d_selected = sel;
}
}
yy += _cw + ui(12);
hh += _cw + ui(12);
} else {
drawColor(CURRENT_COLOR, _cx, yy, _cw, _cw); drawColor(CURRENT_COLOR, _cx, yy, _cw, _cw);
draw_sprite_stretched_ext(THEME.palette_selecting, 0, _cx - _pd, yy - _pd, _cw + _pd * 2, _cw + _pd * 2, c_white, 1); draw_sprite_stretched_ext(THEME.palette_selecting, 0, _cx - _pd, yy - _pd, _cw + _pd * 2, _cw + _pd * 2, c_white, 1);
if(point_in_rectangle(_mx, _my, _cx, yy, _cx + _cw, yy + _ch) && mouse_press(mb_left, focus)) if(point_in_rectangle(_mx, _my, _cx, yy, _cx + _cw, yy + _cw) && mouse_press(mb_left, focus))
colorSelectorCall(CURRENT_COLOR, setToolColor); colorSelectorCall(CURRENT_COLOR, setToolColor);
yy += _cw + ui(8); yy += _cw + ui(8);
hh += _cw + ui(8); hh += _cw + ui(8);
}
var _sel = noone; var _sel = noone;
for( var i = 0, n = array_length(DEF_PALETTE); i < n; i++ ) { for( var i = 0, n = array_length(DEF_PALETTE); i < n; i++ ) {
@ -438,12 +482,12 @@ function Node_Canvas(_x, _y, _group = noone) : Node(_x, _y, _group) constructor
draw_sprite_stretched_ext(THEME.palette_mask, ii, _cx, yy, _cw, _ch, _c, 1); draw_sprite_stretched_ext(THEME.palette_mask, ii, _cx, yy, _cw, _ch, _c, 1);
if(color_diff(_c, CURRENT_COLOR) <= 0) if(color_diff(_c, _currc) <= 0)
_sel = [ _cx, yy ]; _sel = [ _cx, yy ];
if(hover && point_in_rectangle(_mx, _my, _cx, yy, _cx + _cw, yy + _ch)) { if(hover && point_in_rectangle(_mx, _my, _cx, yy, _cx + _cw, yy + _ch)) {
if(mouse_click(mb_left, focus)) if(mouse_click(mb_left, focus))
CURRENT_COLOR = _c; setToolColor(_c);
} }
yy += _ch; yy += _ch;
@ -703,6 +747,7 @@ function Node_Canvas(_x, _y, _group = noone) : Node(_x, _y, _group) constructor
#region tool #region tool
var _currTool = PANEL_PREVIEW.tool_current; var _currTool = PANEL_PREVIEW.tool_current;
var _tool = noone; var _tool = noone;
use_color_3d = false;
rightTools = []; rightTools = [];
array_append(rightTools, rightTools_general); array_append(rightTools, rightTools_general);
@ -718,6 +763,8 @@ function Node_Canvas(_x, _y, _group = noone) : Node(_x, _y, _group) constructor
_tool = _tool.getTool(); _tool = _tool.getTool();
_tool.subtool = _currTool.selecting; _tool.subtool = _currTool.selecting;
array_append(rightTools, _tool.rightTools); array_append(rightTools, _tool.rightTools);
use_color_3d = _tool.use_color_3d;
} }
} }

View file

@ -251,11 +251,15 @@ function Node_Canvas_Group(_x, _y, _group) : Node_Collection(_x, _y, _group) con
if(canvas_sel) canvas_sel.drawOverlay(hover, active, _x, _y, _s, _mx, _my, _snx, _sny); if(canvas_sel) canvas_sel.drawOverlay(hover, active, _x, _y, _s, _mx, _my, _snx, _sny);
} }
static drawTools = function(_mx, _my, xx, yy, tool_size, hover, focus) {
if(canvas_sel) return canvas_sel.drawTools(_mx, _my, xx, yy, tool_size, hover, focus);
return 0;
}
static step = function() { static step = function() {
tools = -1; tools = -1;
tool_settings = []; tool_settings = [];
rightTools = -1; rightTools = -1;
drawTools = -1;
canvas_sel = noone; canvas_sel = noone;
@ -276,7 +280,6 @@ function Node_Canvas_Group(_x, _y, _group) : Node_Collection(_x, _y, _group) con
tools = canvas_sel.tools; tools = canvas_sel.tools;
tool_settings = canvas_sel.tool_settings; tool_settings = canvas_sel.tool_settings;
rightTools = canvas_sel.rightTools; rightTools = canvas_sel.rightTools;
drawTools = canvas_sel.drawTools;
} }
if(timeline_item_group) { if(timeline_item_group) {

View file

@ -1557,39 +1557,40 @@ function NodeValue(_name, _node, _connect, _type, _value, _tooltip = "") constru
return self; return self;
} #endregion } #endregion
static isConnectable = function(_valueFrom, checkRecur = true, log = false) { #region static isConnectable = function(_valueFrom, checkRecur = true, _log = false) { #region
if(_valueFrom == -1 || _valueFrom == undefined || _valueFrom == noone) { if(_valueFrom == -1 || _valueFrom == undefined || _valueFrom == noone) {
if(log) noti_warning($"LOAD: Cannot set node connection from {_valueFrom} to {name} of node {node.name}.",, node); if(_log) noti_warning($"LOAD: Cannot set node connection from {_valueFrom} to {name} of node {node.name}.",, node);
return -1; return -1;
} }
if(_valueFrom == value_from) { if(_valueFrom == value_from) {
if(log) noti_warning("whaT"); if(_log) noti_warning("whaT");
return -2; return -2;
} }
if(_valueFrom == self) { if(_valueFrom == self) {
if(log) noti_warning("setFrom: Self connection is not allowed.",, node); if(_log) noti_warning("setFrom: Self connection is not allowed.",, node);
return -3; return -3;
} }
if(!typeCompatible(_valueFrom.type, type)) { if(!typeCompatible(_valueFrom.type, type)) {
noti_warning($"Connection error: Incompatible type {_valueFrom.type} to {type}",, node); if(_log) noti_warning($"Connection error: Incompatible type {_valueFrom.type} to {type}",, node);
return -4; return -4;
} }
if(typeIncompatible(_valueFrom, self)) { if(typeIncompatible(_valueFrom, self)) {
noti_warning("Connection error: Incompatible type",, node); if(_log) noti_warning("Connection error: Incompatible type",, node);
return -5; return -5;
} }
if(connect_type == _valueFrom.connect_type) { if(connect_type == _valueFrom.connect_type) {
if(log) noti_warning("setFrom: Connect type mismatch",, node); if(_log) noti_warning("setFrom: Connect type mismatch",, node);
return -6; return -6;
} }
if(checkRecur && _valueFrom.searchNodeBackward(node)) { if(checkRecur && _valueFrom.searchNodeBackward(node)) {
if(log) noti_warning("setFrom: Cyclic connection not allowed.",, node); if(_log) noti_warning("setFrom: Cyclic connection not allowed.",, node);
return -7; return -7;
} }
@ -1599,7 +1600,7 @@ function NodeValue(_name, _node, _connect, _type, _value, _tooltip = "") constru
} }
if(!accept_array && _valueFrom.type == VALUE_TYPE.surface && (type == VALUE_TYPE.integer || type == VALUE_TYPE.float)) { if(!accept_array && _valueFrom.type == VALUE_TYPE.surface && (type == VALUE_TYPE.integer || type == VALUE_TYPE.float)) {
if(log) noti_warning("setFrom: Array mismatch",, node); if(_log) noti_warning("setFrom: Array mismatch",, node);
return -9; return -9;
} }

View file

@ -1,5 +1,5 @@
{ {
"$GMScript":"v1", "$GMScript":"",
"%Name":"node_value", "%Name":"node_value",
"isCompatibility":false, "isCompatibility":false,
"isDnD":false, "isDnD":false,

View file

@ -1559,7 +1559,7 @@ function Panel_Graph(project = PROJECT) : PanelContent() constructor {
if(is_instanceof(PANEL_INSPECTOR, Panel_Inspector) && PANEL_INSPECTOR.attribute_hovering != noone) { if(is_instanceof(PANEL_INSPECTOR, Panel_Inspector) && PANEL_INSPECTOR.attribute_hovering != noone) {
PANEL_INSPECTOR.attribute_hovering(value_dragging); PANEL_INSPECTOR.attribute_hovering(value_dragging);
} else if(target != noone) { } else if(target != noone && target != value_dragging) {
if(target.connect_type == value_dragging.connect_type) { if(target.connect_type == value_dragging.connect_type) {

View file

@ -1,5 +1,5 @@
{ {
"$GMScript":"v1", "$GMScript":"",
"%Name":"panel_graph", "%Name":"panel_graph",
"isCompatibility":false, "isCompatibility":false,
"isDnD":false, "isDnD":false,