1
0
Fork 0
mirror of https://github.com/Orama-Interactive/Pixelorama.git synced 2025-01-18 17:19:50 +00:00

Drawing is no longer limited by the canvas boundaries

his means that, if you have a brush largen than 1px, you can draw on the edges of the canvas. All pixels that are being drawn outside of the canvas will still have no effect.
This commit is contained in:
OverloadedOrama 2020-05-31 01:07:08 +03:00
parent 4fc2888b68
commit bda9e6267d
2 changed files with 43 additions and 59 deletions

View file

@ -14,6 +14,9 @@ Igor Santarek (jegor377)
- You can now drag & drop files into the program while it's running to open them.
<br><br>
### Changed
- Drawing is no longer limited by the canvas boundaries. This means that, if you have a brush largen than 1px, you can draw on the edges of the canvas. All pixels that are being drawn outside of the canvas will still have no effect.
## [v0.7] - 2020-05-16
This update has been brought to you by the contributions of:

View file

@ -169,7 +169,6 @@ func _draw() -> void:
# Draw rectangle to indicate the pixel currently being hovered on
var mouse_pos := current_pixel
if point_in_rectangle(mouse_pos, location, location + size):
mouse_pos = mouse_pos.floor()
if Global.left_square_indicator_visible && Global.can_draw:
if Global.current_left_brush_type == Global.Brush_Types.PIXEL || Global.current_left_tool == "LightenDarken":
@ -252,7 +251,6 @@ func _input(event : InputEvent) -> void:
var mouse_pos := current_pixel
var mouse_pos_floored := mouse_pos.floor()
var mouse_pos_ceiled := mouse_pos.ceil()
var mouse_in_canvas := point_in_rectangle(mouse_pos, location, location + size)
var current_mouse_button := "None"
var current_action := "None"
var current_color : Color
@ -293,7 +291,7 @@ func _input(event : InputEvent) -> void:
color_picker_for = Global.right_color_picker_for
zoom_mode = Global.right_zoom_mode
if mouse_in_canvas && Global.has_focus:
if Global.has_focus:
Global.cursor_position_label.text = "[%s×%s] %s, %s" % [size.x, size.y, mouse_pos_floored.x, mouse_pos_floored.y]
if !cursor_inside_canvas:
cursor_inside_canvas = true
@ -315,19 +313,9 @@ func _input(event : InputEvent) -> void:
Input.set_custom_mouse_cursor(null)
# Handle Undo/Redo
var can_handle : bool = mouse_in_canvas && Global.can_draw && Global.has_focus && !made_line
var can_handle : bool = Global.can_draw && Global.has_focus && !made_line
var mouse_pressed : bool = (Input.is_action_just_pressed("left_mouse") && !Input.is_action_pressed("right_mouse")) || (Input.is_action_just_pressed("right_mouse") && !Input.is_action_pressed("left_mouse"))
# If we're already pressing a mouse button and we haven't handled undo yet,...
#. .. it means that the cursor was outside the canvas. Then, ...
# simulate "just pressed" logic the moment the cursor gets inside the canvas
# Or, if we're making a line. This is used for handling undo/redo for lines...
# ...that go outside the canvas
if Input.is_action_pressed("left_mouse") || Input.is_action_pressed("right_mouse"):
if (mouse_in_canvas && Global.undos < Global.undo_redo.get_version()) || is_making_line:
mouse_pressed = true
if mouse_pressed:
if can_handle || is_making_line:
if current_action != "None" && current_action != "ColorPicker" && current_action != "Zoom":
@ -511,8 +499,6 @@ func _input(event : InputEvent) -> void:
previous_action = current_action
previous_mouse_pos = current_pixel
previous_mouse_pos.x = clamp(previous_mouse_pos.x, location.x, location.x + size.x)
previous_mouse_pos.y = clamp(previous_mouse_pos.y, location.y, location.y + size.y)
if sprite_changed_this_frame:
update_texture(Global.current_layer)
@ -602,14 +588,9 @@ func pencil_and_eraser(sprite : Image, mouse_pos : Vector2, color : Color, curre
DrawingAlgos.draw_brush(sprite, line_2d.points[1], color, current_mouse_button, pen_pressure, current_action)
made_line = true
else:
if point_in_rectangle(mouse_pos, location, location + size):
mouse_inside_canvas = true
# Draw
DrawingAlgos.draw_brush(sprite, mouse_pos, color, current_mouse_button, pen_pressure, current_action)
DrawingAlgos.fill_gaps(sprite, mouse_pos, previous_mouse_pos, color, current_mouse_button, pen_pressure, current_action) # Fill the gaps
# If mouse is not inside bounds but it used to be, fill the gaps
elif point_in_rectangle(previous_mouse_pos, location, location + size):
DrawingAlgos.fill_gaps(sprite, mouse_pos, previous_mouse_pos, color, current_mouse_button, pen_pressure, current_action)
# Checks if a point is inside a rectangle