diff --git a/scripts/__canvas_brush/__canvas_brush.gml b/scripts/__canvas_brush/__canvas_brush.gml index e6b08447e..7fe7df820 100644 --- a/scripts/__canvas_brush/__canvas_brush.gml +++ b/scripts/__canvas_brush/__canvas_brush.gml @@ -9,6 +9,7 @@ function canvas_brush() constructor { brush_rand_dir = [ 0, 0, 0, 0, 0 ]; brush_seed = irandom_range(100000, 999999); brush_next_dist = 0; + brush_range = 0; brush_sizing = false; brush_sizing_s = 0; @@ -20,7 +21,8 @@ function canvas_brush() constructor { mouse_pre_dir_x = undefined; mouse_pre_dir_y = undefined; - node = noone; + tileMode = 0; + node = noone; colors = [ c_white, c_black ]; @@ -49,6 +51,7 @@ function canvas_brush() constructor { } } else brush_surface = is_surface(_brushSurf)? _brushSurf : noone; + brush_range = brush_surface == noone? ceil(brush_size / 2) : max(surface_get_width_safe(brush_surface), surface_get_height_safe(brush_surface)) / 2; if(!_brushRotD) brush_direction = 0; diff --git a/scripts/canvas_tool_brush/canvas_tool_brush.gml b/scripts/canvas_tool_brush/canvas_tool_brush.gml index b591d5810..6b5b2f1ac 100644 --- a/scripts/canvas_tool_brush/canvas_tool_brush.gml +++ b/scripts/canvas_tool_brush/canvas_tool_brush.gml @@ -4,10 +4,12 @@ function canvas_tool_brush(brush, eraser = false) : canvas_tool() constructor { brush_resizable = true; - mouse_cur_x = 0; - mouse_cur_y = 0; - mouse_pre_x = 0; - mouse_pre_y = 0; + mouse_cur_x = 0; + mouse_cur_y = 0; + mouse_cur_tx = 0; + mouse_cur_ty = 0; + mouse_pre_x = 0; + mouse_pre_y = 0; mouse_pre_draw_x = undefined; mouse_pre_draw_y = undefined; @@ -17,6 +19,64 @@ function canvas_tool_brush(brush, eraser = false) : canvas_tool() constructor { mouse_line_x1 = 0; mouse_line_y1 = 0; + brush_warp = false; + warp_block_x = 0; + warp_block_y = 0; + warp_block_px = 0; + warp_block_py = 0; + + draw_w = 1; + draw_h = 1; + + function draw_point_wrap(_draw = true) { + var _oxn = mouse_cur_tx - brush.brush_range < 0; + var _oxp = mouse_cur_tx + brush.brush_range > draw_w; + var _oyn = mouse_cur_ty - brush.brush_range < 0; + var _oyp = mouse_cur_ty + brush.brush_range > draw_h; + + if(brush.tileMode & 0b01) { + if(_oxn) canvas_draw_point_brush(brush, draw_w + mouse_cur_tx, mouse_cur_ty, _draw); + else if(_oxp) canvas_draw_point_brush(brush, mouse_cur_tx - draw_w, mouse_cur_ty, _draw); + } + + if(brush.tileMode & 0b10) { + if(_oyn) canvas_draw_point_brush(brush, mouse_cur_tx, draw_h + mouse_cur_ty, _draw); + else if(_oyp) canvas_draw_point_brush(brush, mouse_cur_tx, mouse_cur_ty - draw_h, _draw); + } + + if(brush.tileMode == 0b11) { + if(_oxn && _oyn) canvas_draw_point_brush(brush, draw_w + mouse_cur_tx, draw_h + mouse_cur_ty, _draw); + else if(_oxn && _oyp) canvas_draw_point_brush(brush, draw_w + mouse_cur_tx, mouse_cur_ty - draw_h, _draw); + + else if(_oxp && _oyn) canvas_draw_point_brush(brush, mouse_cur_tx - draw_w, draw_h + mouse_cur_ty, _draw); + else if(_oxp && _oyp) canvas_draw_point_brush(brush, mouse_cur_tx - draw_w, mouse_cur_ty - draw_h, _draw); + } + + canvas_draw_point_brush(brush, mouse_cur_tx, mouse_cur_ty, _draw); + } + + function draw_line_wrap(_draw = true) { + if(!brush_warp) canvas_draw_line_brush(brush, mouse_pre_draw_x, mouse_pre_draw_y, mouse_cur_tx, mouse_cur_ty, _draw); + else { + if(warp_block_x > warp_block_px) { + canvas_draw_line_brush(brush, mouse_pre_draw_x, mouse_pre_draw_y, draw_w + mouse_cur_tx, mouse_cur_ty, _draw); + canvas_draw_line_brush(brush, mouse_pre_draw_x - draw_w, mouse_pre_draw_y, mouse_cur_tx, mouse_cur_ty, _draw); + } else if(warp_block_x < warp_block_px) { + canvas_draw_line_brush(brush, mouse_pre_draw_x, mouse_pre_draw_y, mouse_cur_tx - draw_w, mouse_cur_ty, _draw); + canvas_draw_line_brush(brush, draw_w + mouse_pre_draw_x, mouse_pre_draw_y, mouse_cur_tx, mouse_cur_ty, _draw); + } + + if(warp_block_y > warp_block_py) { + canvas_draw_line_brush(brush, mouse_pre_draw_x, mouse_pre_draw_y, mouse_cur_tx, draw_h + mouse_cur_ty, _draw); + canvas_draw_line_brush(brush, mouse_pre_draw_x, mouse_pre_draw_y - draw_h, mouse_cur_tx, mouse_cur_ty, _draw); + } else if(warp_block_y < warp_block_py) { + canvas_draw_line_brush(brush, mouse_pre_draw_x, mouse_pre_draw_y, mouse_cur_tx, mouse_cur_ty - draw_h, _draw); + canvas_draw_line_brush(brush, mouse_pre_draw_x, draw_h + mouse_pre_draw_y, mouse_cur_tx, mouse_cur_ty, _draw); + } + + } + } + function step(hover, active, _x, _y, _s, _mx, _my, _snx, _sny) { mouse_cur_x = round((_mx - _x) / _s - 0.5); @@ -46,72 +106,99 @@ function canvas_tool_brush(brush, eraser = false) : canvas_tool() constructor { } } + mouse_cur_tx = mouse_cur_x; + mouse_cur_ty = mouse_cur_y; + draw_w = surface_get_width(drawing_surface); + draw_h = surface_get_height(drawing_surface); + + if(brush.tileMode & 0b01) { + warp_block_x = floor(mouse_cur_x / draw_w); + mouse_cur_tx = safe_mod(mouse_cur_tx, draw_w, MOD_NEG.wrap); + } + + if(brush.tileMode & 0b10) { + warp_block_y = floor(mouse_cur_y / draw_h); + mouse_cur_ty = safe_mod(mouse_cur_ty, draw_h, MOD_NEG.wrap); + } + + brush_warp = warp_block_x != warp_block_px || warp_block_y != warp_block_py; + if(mouse_press(mb_left, active)) { surface_set_shader(drawing_surface, noone); - canvas_draw_point_brush(brush, mouse_cur_x, mouse_cur_y, true); + draw_point_wrap(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_brush(brush, mouse_pre_draw_x, mouse_pre_draw_y, mouse_cur_x, mouse_cur_y, true); + draw_line_wrap(true); surface_reset_shader(); mouse_holding = false; apply_draw_surface(); } - node.tool_pick_color(mouse_cur_x, mouse_cur_y); + node.tool_pick_color(mouse_cur_tx, mouse_cur_ty); - mouse_pre_draw_x = mouse_cur_x; - mouse_pre_draw_y = mouse_cur_y; + mouse_pre_draw_x = mouse_cur_tx; + mouse_pre_draw_y = mouse_cur_ty; + + warp_block_px = warp_block_x; + warp_block_py = warp_block_y; + } if(mouse_holding) { - var _move = mouse_pre_draw_x != mouse_cur_x || mouse_pre_draw_y != mouse_cur_y; + var _move = mouse_pre_draw_x != mouse_cur_tx || mouse_pre_draw_y != mouse_cur_ty; var _1stp = brush.brush_dist_min == brush.brush_dist_max && brush.brush_dist_min == 1; if(_move || !_1stp) { surface_set_shader(drawing_surface, noone, false, BLEND.alpha); - 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); + if(_1stp) draw_point_wrap(true); + + draw_line_wrap(true); surface_reset_shader(); } - mouse_pre_draw_x = mouse_cur_x; - mouse_pre_draw_y = mouse_cur_y; + mouse_pre_draw_x = mouse_cur_tx; + mouse_pre_draw_y = mouse_cur_ty; + warp_block_px = warp_block_x; + warp_block_py = warp_block_y; + if(mouse_release(mb_left)) { - mouse_holding = false; + mouse_holding = false; apply_draw_surface(); } + } BLEND_NORMAL; mouse_pre_x = mouse_cur_x; mouse_pre_y = mouse_cur_y; - + } function drawPreview(hover, active, _x, _y, _s, _mx, _my, _snx, _sny) { if(isEraser) draw_set_color(c_white); mouse_line_drawing = false; - //print($"Drawing {mouse_cur_x}, {mouse_cur_y}, [{draw_get_color()}, {draw_get_alpha()}] {surface_get_target()}"); 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); + draw_line_wrap(false); 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); + return; + } + + draw_point_wrap(false); } function drawPostOverlay(hover, active, _x, _y, _s, _mx, _my, _snx, _sny) { diff --git a/scripts/canvas_tool_brush_shape/canvas_tool_brush_shape.gml b/scripts/canvas_tool_brush_shape/canvas_tool_brush_shape.gml index 3b0ca4518..5b17fa91b 100644 --- a/scripts/canvas_tool_brush_shape/canvas_tool_brush_shape.gml +++ b/scripts/canvas_tool_brush_shape/canvas_tool_brush_shape.gml @@ -15,6 +15,95 @@ function canvas_tool_shape(brush, shape) : canvas_tool() constructor { mouse_pre_x = 0; mouse_pre_y = 0; + draw_w = 1; + draw_h = 1; + + function draw_point_wrap(_draw = true) { + var _oxn = mouse_cur_tx - brush.brush_range < 0; + var _oxp = mouse_cur_tx + brush.brush_range > draw_w; + var _oyn = mouse_cur_ty - brush.brush_range < 0; + var _oyp = mouse_cur_ty + brush.brush_range > draw_h; + + if(brush.tileMode & 0b01) { + if(_oxn) canvas_draw_point_brush(brush, draw_w + mouse_cur_tx, mouse_cur_ty, _draw); + else if(_oxp) canvas_draw_point_brush(brush, mouse_cur_tx - draw_w, mouse_cur_ty, _draw); + } + + if(brush.tileMode & 0b10) { + if(_oyn) canvas_draw_point_brush(brush, mouse_cur_tx, draw_h + mouse_cur_ty, _draw); + else if(_oyp) canvas_draw_point_brush(brush, mouse_cur_tx, mouse_cur_ty - draw_h, _draw); + } + + if(brush.tileMode == 0b11) { + if(_oxn && _oyn) canvas_draw_point_brush(brush, draw_w + mouse_cur_tx, draw_h + mouse_cur_ty, _draw); + else if(_oxn && _oyp) canvas_draw_point_brush(brush, draw_w + mouse_cur_tx, mouse_cur_ty - draw_h, _draw); + + else if(_oxp && _oyn) canvas_draw_point_brush(brush, mouse_cur_tx - draw_w, draw_h + mouse_cur_ty, _draw); + else if(_oxp && _oyp) canvas_draw_point_brush(brush, mouse_cur_tx - draw_w, mouse_cur_ty - draw_h, _draw); + } + + canvas_draw_point_brush(brush, mouse_cur_tx, mouse_cur_ty, _draw); + } + + function draw_shape() { + var _x0 = min(mouse_pre_x, mouse_cur_x); + var _x1 = max(mouse_pre_x, mouse_cur_x); + var _y0 = min(mouse_pre_y, mouse_cur_y); + var _y1 = max(mouse_pre_y, mouse_cur_y); + + var _x0b = _x0 - brush.brush_range; + var _x1b = _x1 + brush.brush_range; + var _y0b = _y0 - brush.brush_range; + var _y1b = _y1 + brush.brush_range; + + var _bx0 = floor(_x0b / draw_w); + var _bx1 = floor(_x1b / draw_w); + var _by0 = floor(_y0b / draw_h); + var _by1 = floor(_y1b / draw_h); + + var _drawFn = canvas_draw_rect_brush; + + switch(shape) { + case CANVAS_TOOL_SHAPE.rectangle : _drawFn = canvas_draw_rect_brush; break; + case CANVAS_TOOL_SHAPE.ellipse : _drawFn = canvas_draw_ellp_brush; break; + } + + if(brush.tileMode == 0) { + _drawFn(brush, _x0, _y0, _x1, _y1, subtool); + return; + } + + var _x0t = safe_mod(_x0, draw_w, MOD_NEG.wrap); + var _x1t = _x1 + (_x0t - _x0); + var _y0t = safe_mod(_y0, draw_w, MOD_NEG.wrap); + var _y1t = _y1 + (_y0t - _y0); + + if(_bx0 == _bx1 && _by0 == _by1) { + _drawFn(brush, _x0t, _y0t, _x1t, _y1t, subtool); + return; + } + + _drawFn(brush, _x0t, _y0t, _x1t, _y1t, subtool); + + if(brush.tileMode & 0b01) { + _drawFn(brush, _x0t + draw_w, _y0t, _x1t + draw_w, _y1t, subtool); + _drawFn(brush, _x0t - draw_w, _y0t, _x1t - draw_w, _y1t, subtool); + } + + if(brush.tileMode & 0b10) { + _drawFn(brush, _x0t, _y0t + draw_h, _x1t, _y1t + draw_h, subtool); + _drawFn(brush, _x0t, _y0t - draw_h, _x1t, _y1t - draw_h, subtool); + } + + if(brush.tileMode & 0b11) { + _drawFn(brush, _x0t + draw_w, _y0t + draw_h, _x1t + draw_w, _y1t + draw_h, subtool); + _drawFn(brush, _x0t + draw_w, _y0t - draw_h, _x1t + draw_w, _y1t - draw_h, subtool); + + _drawFn(brush, _x0t - draw_w, _y0t + draw_h, _x1t - draw_w, _y1t + draw_h, subtool); + _drawFn(brush, _x0t - draw_w, _y0t - draw_h, _x1t - draw_w, _y1t - draw_h, subtool); + } + } + function step(hover, active, _x, _y, _s, _mx, _my, _snx, _sny) { mouse_cur_x = round((_mx - _x) / _s - 0.5); @@ -29,13 +118,18 @@ function canvas_tool_shape(brush, shape) : canvas_tool() constructor { mouse_cur_y = mouse_pre_y + ss * sign(hh); } + mouse_cur_tx = mouse_cur_x; + mouse_cur_ty = mouse_cur_y; + draw_w = surface_get_width(drawing_surface); + draw_h = surface_get_height(drawing_surface); + + if(brush.tileMode & 0b01) mouse_cur_tx = safe_mod(mouse_cur_tx, draw_w, MOD_NEG.wrap); + if(brush.tileMode & 0b10) mouse_cur_ty = safe_mod(mouse_cur_ty, draw_h, MOD_NEG.wrap); + if(mouse_holding) { surface_set_shader(drawing_surface, noone); - switch(shape) { - 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; - } + draw_shape(); surface_reset_shader(); if(mouse_release(mb_left)) { @@ -44,11 +138,12 @@ function canvas_tool_shape(brush, shape) : canvas_tool() constructor { } } else if(mouse_press(mb_left, active)) { - mouse_pre_x = mouse_cur_x; - mouse_pre_y = mouse_cur_y; mouse_holding = true; + mouse_pre_x = mouse_cur_x; + mouse_pre_y = mouse_cur_y; + node.tool_pick_color(mouse_cur_x, mouse_cur_y); } @@ -57,14 +152,11 @@ function canvas_tool_shape(brush, shape) : canvas_tool() constructor { function drawPreview(hover, active, _x, _y, _s, _mx, _my, _snx, _sny) { if(!mouse_holding) { - canvas_draw_point_brush(brush, mouse_cur_x, mouse_cur_y); + draw_point_wrap(false); return; } - switch(shape) { - 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; - } + draw_shape(); } function drawPostOverlay(hover, active, _x, _y, _s, _mx, _my, _snx, _sny) { diff --git a/scripts/node_blur_bokeh/node_blur_bokeh.gml b/scripts/node_blur_bokeh/node_blur_bokeh.gml index 6640dc4b9..d03297fab 100644 --- a/scripts/node_blur_bokeh/node_blur_bokeh.gml +++ b/scripts/node_blur_bokeh/node_blur_bokeh.gml @@ -4,7 +4,6 @@ function Node_Blur_Bokeh(_x, _y, _group = noone) : Node_Processor(_x, _y, _group newInput(0, nodeValue_Surface("Surface in", self)); newInput(1, nodeValue_Float("Strength", self, 0.2)) - .setDisplay(VALUE_DISPLAY.slider, { range: [0, 16, 0.01] }) .setMappable(8); newInput(2, nodeValue_Surface("Mask", self)); @@ -34,13 +33,13 @@ function Node_Blur_Bokeh(_x, _y, _group = noone) : Node_Processor(_x, _y, _group attribute_surface_depth(); - static step = function() { #region + static step = function() { __step_mask_modifier(); inputs[1].mappableStep(); - } #endregion + } - static processData = function(_outSurf, _data, _output_index, _array_index) { #region + static processData = function(_outSurf, _data, _output_index, _array_index) { surface_set_shader(_outSurf, sh_blur_bokeh); shader_set_f("dimension", surface_get_width_safe(_data[0]), surface_get_height_safe(_data[0])); @@ -54,5 +53,5 @@ function Node_Blur_Bokeh(_x, _y, _group = noone) : Node_Processor(_x, _y, _group _outSurf = channel_apply(_data[0], _outSurf, _data[5]); return _outSurf; - } #endregion + } } \ No newline at end of file diff --git a/scripts/node_blur_contrast/node_blur_contrast.gml b/scripts/node_blur_contrast/node_blur_contrast.gml index a1177a4ee..12119ced0 100644 --- a/scripts/node_blur_contrast/node_blur_contrast.gml +++ b/scripts/node_blur_contrast/node_blur_contrast.gml @@ -4,7 +4,8 @@ function Node_Blur_Contrast(_x, _y, _group = noone) : Node_Processor(_x, _y, _gr newInput(0, nodeValue_Surface("Surface in", self)); newInput(1, nodeValue_Float("Size", self, 3)) - .setDisplay(VALUE_DISPLAY.slider, { range: [1, 32, 0.1] }); + .setValidator(VV_min(0)) + .setUnitRef(function(index) /*=>*/ {return getDimension(index)}); newInput(2, nodeValue_Float("Threshold", self, 0.2, "Brightness different to be blur together.")) .setDisplay(VALUE_DISPLAY.slider); @@ -34,11 +35,11 @@ function Node_Blur_Contrast(_x, _y, _group = noone) : Node_Processor(_x, _y, _gr attribute_surface_depth(); - static step = function() { #region + static step = function() { __step_mask_modifier(); - } #endregion + } - static processData = function(_outSurf, _data, _output_index, _array_index) { #region + static processData = function(_outSurf, _data, _output_index, _array_index) { var _surf = _data[0]; var _size = _data[1]; var _tres = _data[2]; @@ -63,5 +64,5 @@ function Node_Blur_Contrast(_x, _y, _group = noone) : Node_Processor(_x, _y, _gr _outSurf = channel_apply(_data[0], _outSurf, _data[6]); return _outSurf; - } #endregion + } } \ No newline at end of file diff --git a/scripts/node_blur_simple/node_blur_simple.gml b/scripts/node_blur_simple/node_blur_simple.gml index e415a5bbd..bd6c504a0 100644 --- a/scripts/node_blur_simple/node_blur_simple.gml +++ b/scripts/node_blur_simple/node_blur_simple.gml @@ -3,7 +3,8 @@ function Node_Blur_Simple(_x, _y, _group = noone) : Node_Processor(_x, _y, _grou newInput(0, nodeValue_Surface("Surface in", self)); newInput(1, nodeValue_Float("Size", self, 3)) - .setDisplay(VALUE_DISPLAY.slider, { range: [1, 32, 0.1] }); + .setValidator(VV_min(0)) + .setUnitRef(function(index) /*=>*/ {return getDimension(index)}); newInput(2, nodeValue_Enum_Scroll("Oversample mode", self, 0, [ "Empty", "Clamp", "Repeat" ])) .setTooltip("How to deal with pixel outside the surface.\n - Empty: Use empty pixel\n - Clamp: Repeat edge pixel\n - Repeat: Repeat texture."); @@ -48,13 +49,13 @@ function Node_Blur_Simple(_x, _y, _group = noone) : Node_Processor(_x, _y, _grou attribute_surface_depth(); attribute_oversample(); - static step = function() { #region + static step = function() { __step_mask_modifier(); inputs[12].mappableStep(); - } #endregion + } - static processData = function(_outSurf, _data, _output_index, _array_index) { #region + static processData = function(_outSurf, _data, _output_index, _array_index) { if(!is_surface(_data[0])) return _outSurf; var _size = _data[1]; var _samp = struct_try_get(attributes, "oversample"); @@ -91,5 +92,5 @@ function Node_Blur_Simple(_x, _y, _group = noone) : Node_Processor(_x, _y, _grou _outSurf = channel_apply(_data[0], _outSurf, _data[9]); return _outSurf; - } #endregion + } } \ No newline at end of file diff --git a/scripts/node_canvas/node_canvas.gml b/scripts/node_canvas/node_canvas.gml index 869a91b5d..8163f66d7 100644 --- a/scripts/node_canvas/node_canvas.gml +++ b/scripts/node_canvas/node_canvas.gml @@ -200,6 +200,7 @@ function Node_Canvas(_x, _y, _group = noone) : Node(_x, _y, _group) constructor prev_surface = surface_create_empty(1, 1); preview_draw_surface = surface_create_empty(1, 1); + preview_draw_tile = surface_create_empty(1, 1); preview_draw_mask = surface_create_empty(1, 1); draw_stack = ds_list_create(); @@ -718,10 +719,13 @@ function Node_Canvas(_x, _y, _group = noone) : Node(_x, _y, _group) constructor } - static drawOverlay = function(hover, active, _x, _y, _s, _mx, _my, _snx, _sny) { + static drawOverlay = function(hover, active, _x, _y, _s, _mx, _my, _snx, _sny, params) { if(instance_exists(o_dialog_color_picker)) return; - brush.node = self; + var _panel = params.panel; + + brush.node = self; + brush.tileMode = _panel.tileMode brush.step(hover, active, _x, _y, _s, _mx, _my, _snx, _sny); if(!tool_selection.is_selected && active && key_mod_press(ALT)) { // color selector @@ -892,7 +896,32 @@ function Node_Canvas(_x, _y, _group = noone) : Node(_x, _y, _group) constructor draw_set_alpha(1); surface_reset_shader(); - draw_surface_ext_safe(preview_draw_surface, _x, _y, _s, _s, 0, isUsingTool("Eraser")? c_red : c_white, isUsingTool("Eraser")? .2 : _alp); + var _pcc = isUsingTool("Eraser")? c_red : c_white; + var _paa = isUsingTool("Eraser")? .2 : _alp; + + switch(_panel.tileMode) { + case 0 : draw_surface_ext_safe(preview_draw_surface, _x, _y, _s, _s, 0, _pcc, _paa); break; + + case 1 : + preview_draw_tile = surface_verify(preview_draw_tile, _panel.w, _dim[1] * _s); + surface_set_target(preview_draw_tile); + DRAW_CLEAR + draw_surface_tiled_ext_safe(preview_draw_surface, _x, 0, _s, _s, 0, _pcc, _paa); + surface_reset_target(); + draw_surface_safe(preview_draw_tile, 0, _y); + break; + + case 2 : + preview_draw_tile = surface_verify(preview_draw_tile, _dim[0] * _s, _panel.h); + surface_set_target(preview_draw_tile); + DRAW_CLEAR + draw_surface_tiled_ext_safe(preview_draw_surface, 0, _y, _s, _s, 0, _pcc, _paa); + surface_reset_target(); + draw_surface_safe(preview_draw_tile, _x, 0); + break; + + case 3 : draw_surface_tiled_ext_safe(preview_draw_surface, _x, _y, _s, _s, 0, _pcc, _paa); break; + } surface_set_target(preview_draw_mask); DRAW_CLEAR diff --git a/scripts/node_value/node_value.gml b/scripts/node_value/node_value.gml index 3222b3c9a..7d92db0fe 100644 --- a/scripts/node_value/node_value.gml +++ b/scripts/node_value/node_value.gml @@ -1506,7 +1506,7 @@ function NodeValue(_name, _node, _connect, _type, _value, _tooltip = "") constru INLINE var res = false; - var val = unit.invApply(_val); + // _val = unit.invApply(_val); if(PANEL_INSPECTOR && PANEL_INSPECTOR.inspectGroup == 1) { var ind = self.index; @@ -1515,11 +1515,11 @@ function NodeValue(_name, _node, _connect, _type, _value, _tooltip = "") constru var _node = PANEL_INSPECTOR.inspectings[i]; if(ind >= array_length(_node.inputs)) continue; - var r = _node.inputs[ind].setValueDirect(val, index, true, time); + var r = _node.inputs[ind].setValueDirect(_val, index, true, time); if(_node == node) res = r; } } else - res = setValueDirect(val, index, true, time); + res = setValueDirect(_val, index, true, time); return res; } diff --git a/scripts/node_value_float/node_value_float.gml b/scripts/node_value_float/node_value_float.gml index aaabe5485..999b27592 100644 --- a/scripts/node_value_float/node_value_float.gml +++ b/scripts/node_value_float/node_value_float.gml @@ -4,6 +4,12 @@ function __NodeValue_Float(_name, _node, _value, _tooltip = "") : NodeValue(_nam /////============== GET ============= + static valueProcess = function(value, nodeFrom = undefined, applyUnit = true, arrIndex = 0) { + if(validator != noone) value = validator.validate(value); + value = applyUnit? unit.apply(value, arrIndex) : value; + return value; + } + static getValue = function(_time = CURRENT_FRAME, applyUnit = true, arrIndex = 0, useCache = false, log = false) { //// Get value getValueRecursive(self.__curr_get_val, _time); var val = __curr_get_val[0]; @@ -14,9 +20,7 @@ function __NodeValue_Float(_name, _node, _value, _tooltip = "") : NodeValue(_nam if(typ != VALUE_TYPE.surface) { if(typ == VALUE_TYPE.text) val = toNumber(val); - if(validator != noone) val = validator.validate(val); - - return val; + return valueProcess(val, nod, applyUnit); } // Dimension conversion @@ -39,6 +43,7 @@ function __NodeValue_Float(_name, _node, _value, _tooltip = "") : NodeValue(_nam if(eqSize) return _osZ; return sArr; + } else if (is_surface(val)) return [ surface_get_width_safe(val), surface_get_height_safe(val) ]; diff --git a/scripts/node_value_types/node_value_types.gml b/scripts/node_value_types/node_value_types.gml index 1482f5f12..74d629ce0 100644 --- a/scripts/node_value_types/node_value_types.gml +++ b/scripts/node_value_types/node_value_types.gml @@ -525,10 +525,8 @@ function nodeValueUnit(_nodeValue) constructor { } static invApply = function(value, index = 0) { - if(mode == VALUE_UNIT.constant) - return value; - if(reference == noone) - return value; + if(mode == VALUE_UNIT.constant) return value; + if(reference == noone) return value; return convertUnit(value, VALUE_UNIT.reference, index); }