mirror of
https://github.com/Orama-Interactive/Pixelorama.git
synced 2025-01-18 17:19:50 +00:00
Moved size variable from Canvas.gd to Project.gd
This commit is contained in:
parent
4e111a7ac0
commit
f9bd590d20
|
@ -162,8 +162,8 @@ func draw_brush(sprite : Image, pos : Vector2, color : Color, current_mouse_butt
|
|||
Global.canvas.sprite_changed_this_frame = true
|
||||
|
||||
Global.canvas.previous_mouse_pos_for_lines = pos.floor() + Vector2(0.5, 0.5)
|
||||
Global.canvas.previous_mouse_pos_for_lines.x = clamp(Global.canvas.previous_mouse_pos_for_lines.x, Global.canvas.location.x, Global.canvas.location.x + Global.canvas.size.x)
|
||||
Global.canvas.previous_mouse_pos_for_lines.y = clamp(Global.canvas.previous_mouse_pos_for_lines.y, Global.canvas.location.y, Global.canvas.location.y + Global.canvas.size.y)
|
||||
Global.canvas.previous_mouse_pos_for_lines.x = clamp(Global.canvas.previous_mouse_pos_for_lines.x, Global.canvas.location.x, Global.canvas.location.x + Global.current_project.size.x)
|
||||
Global.canvas.previous_mouse_pos_for_lines.y = clamp(Global.canvas.previous_mouse_pos_for_lines.y, Global.canvas.location.y, Global.canvas.location.y + Global.current_project.size.y)
|
||||
if Global.canvas.is_making_line:
|
||||
Global.canvas.line_2d.set_point_position(0, Global.canvas.previous_mouse_pos_for_lines)
|
||||
|
||||
|
|
|
@ -50,6 +50,7 @@ var right_cursor_tool_texture : ImageTexture
|
|||
var image_clipboard : Image
|
||||
var play_only_tags := true
|
||||
|
||||
# Preferences
|
||||
var theme_type : int = Theme_Types.DARK
|
||||
var default_image_width := 64
|
||||
var default_image_height := 64
|
||||
|
|
|
@ -114,7 +114,7 @@ func open_pxo_file(path : String, untitled_backup : bool = false) -> void:
|
|||
Global.canvas.add_child(guide)
|
||||
guide_line = file.get_line()
|
||||
|
||||
Global.canvas.size = Vector2(width, height)
|
||||
Global.current_project.size = Vector2(width, height)
|
||||
Global.current_project.frames.append(frame_class)
|
||||
frame_line = file.get_line()
|
||||
frame += 1
|
||||
|
@ -214,8 +214,8 @@ func save_pxo_file(path : String, autosave : bool) -> void:
|
|||
# Store frames
|
||||
for frame in Global.current_project.frames:
|
||||
file.store_line("--")
|
||||
file.store_16(Global.canvas.size.x)
|
||||
file.store_16(Global.canvas.size.y)
|
||||
file.store_16(Global.current_project.size.x)
|
||||
file.store_16(Global.current_project.size.y)
|
||||
for cel in frame.cels: # Store canvas layers
|
||||
file.store_line("-")
|
||||
file.store_buffer(cel.image.get_data())
|
||||
|
|
|
@ -3,7 +3,6 @@ extends Node2D
|
|||
|
||||
|
||||
var location := Vector2.ZERO
|
||||
var size := Vector2(64, 64)
|
||||
var fill_color := Color(0, 0, 0, 0)
|
||||
var current_pixel := Vector2.ZERO # pretty much same as mouse_pos, but can be accessed externally
|
||||
var previous_mouse_pos := Vector2.ZERO
|
||||
|
@ -11,10 +10,10 @@ var previous_mouse_pos_for_lines := Vector2.ZERO
|
|||
var can_undo := true
|
||||
var cursor_image_has_changed := false
|
||||
var previous_action := -1
|
||||
var x_min := location.x
|
||||
var x_max := location.x + size.x
|
||||
var y_min := location.y
|
||||
var y_max := location.y + size.y
|
||||
var x_min := 0
|
||||
var x_max := 64
|
||||
var y_min := 0
|
||||
var y_max := 64
|
||||
var sprite_changed_this_frame := false # for optimization purposes
|
||||
var is_making_line := false
|
||||
var made_line := false
|
||||
|
@ -25,6 +24,10 @@ var pen_pressure := 1.0 # For tablet pressure sensitivity
|
|||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready() -> void:
|
||||
x_min = location.x
|
||||
x_max = location.x + Global.current_project.size.x
|
||||
y_min = location.y
|
||||
y_max = location.y + Global.current_project.size.y
|
||||
var frame : Frame = new_empty_frame(true)
|
||||
Global.current_project.frames.append(frame)
|
||||
camera_zoom()
|
||||
|
@ -39,6 +42,7 @@ func _ready() -> void:
|
|||
|
||||
func _draw() -> void:
|
||||
var current_cels : Array = Global.current_project.frames[Global.current_project.current_frame].cels
|
||||
var size : Vector2 = Global.current_project.size
|
||||
if Global.onion_skinning:
|
||||
onion_skinning()
|
||||
|
||||
|
@ -122,9 +126,9 @@ func _input(event : InputEvent) -> void:
|
|||
var current_mouse_button := -1
|
||||
|
||||
x_min = location.x
|
||||
x_max = location.x + size.x
|
||||
x_max = location.x + Global.current_project.size.x
|
||||
y_min = location.y
|
||||
y_max = location.y + size.y
|
||||
y_max = location.y + Global.current_project.size.y
|
||||
if Global.current_project.selected_pixels.size() != 0:
|
||||
x_min = max(x_min, Global.selection_rectangle.polygon[0].x)
|
||||
x_max = min(x_max, Global.selection_rectangle.polygon[2].x)
|
||||
|
@ -140,7 +144,7 @@ func _input(event : InputEvent) -> void:
|
|||
var current_action : int = Global.current_tools[current_mouse_button] if current_mouse_button != -1 else -1
|
||||
|
||||
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]
|
||||
Global.cursor_position_label.text = "[%s×%s] %s, %s" % [Global.current_project.size.x, Global.current_project.size.y, mouse_pos_floored.x, mouse_pos_floored.y]
|
||||
if !cursor_image_has_changed:
|
||||
cursor_image_has_changed = true
|
||||
if Global.cursor_image.get_data().get_size() != Vector2.ZERO:
|
||||
|
@ -150,7 +154,7 @@ func _input(event : InputEvent) -> void:
|
|||
if Global.show_right_tool_icon:
|
||||
Global.right_cursor.visible = true
|
||||
else:
|
||||
Global.cursor_position_label.text = "[%s×%s]" % [size.x, size.y]
|
||||
Global.cursor_position_label.text = "[%s×%s]" % [Global.current_project.size.x, Global.current_project.size.y]
|
||||
if cursor_image_has_changed:
|
||||
cursor_image_has_changed = false
|
||||
Global.left_cursor.visible = false
|
||||
|
@ -231,7 +235,7 @@ func _input(event : InputEvent) -> void:
|
|||
|
||||
func camera_zoom() -> void:
|
||||
# Set camera zoom based on the sprite size
|
||||
var bigger_canvas_axis = max(size.x, size.y)
|
||||
var bigger_canvas_axis = max(Global.current_project.size.x, Global.current_project.size.y)
|
||||
var zoom_max := Vector2(bigger_canvas_axis, bigger_canvas_axis) * 0.01
|
||||
if zoom_max > Vector2.ONE:
|
||||
Global.camera.zoom_max = zoom_max
|
||||
|
@ -242,9 +246,9 @@ func camera_zoom() -> void:
|
|||
Global.camera2.zoom_max = Vector2.ONE
|
||||
Global.camera_preview.zoom_max = Vector2.ONE
|
||||
|
||||
Global.camera.fit_to_frame(size)
|
||||
Global.camera2.fit_to_frame(size)
|
||||
Global.camera_preview.fit_to_frame(size)
|
||||
Global.camera.fit_to_frame(Global.current_project.size)
|
||||
Global.camera2.fit_to_frame(Global.current_project.size)
|
||||
Global.camera_preview.fit_to_frame(Global.current_project.size)
|
||||
|
||||
Global.transparent_checker._ready() # To update the rect size
|
||||
|
||||
|
@ -255,14 +259,13 @@ func new_empty_frame(first_time := false) -> Frame:
|
|||
# The sprite itself
|
||||
var sprite := Image.new()
|
||||
if first_time:
|
||||
if Global.config_cache.has_section_key("preferences", "default_width"):
|
||||
size.x = Global.config_cache.get_value("preferences", "default_width")
|
||||
if Global.config_cache.has_section_key("preferences", "default_height"):
|
||||
size.y = Global.config_cache.get_value("preferences", "default_height")
|
||||
if Global.config_cache.has_section_key("preferences", "default_image_width"):
|
||||
Global.current_project.size.x = Global.config_cache.get_value("preferences", "default_image_width")
|
||||
if Global.config_cache.has_section_key("preferences", "default_image_height"):
|
||||
Global.current_project.size.y = Global.config_cache.get_value("preferences", "default_image_height")
|
||||
if Global.config_cache.has_section_key("preferences", "default_fill_color"):
|
||||
fill_color = Global.config_cache.get_value("preferences", "default_fill_color")
|
||||
|
||||
sprite.create(size.x, size.y, false, Image.FORMAT_RGBA8)
|
||||
sprite.create(Global.current_project.size.x, Global.current_project.size.y, false, Image.FORMAT_RGBA8)
|
||||
sprite.fill(fill_color)
|
||||
sprite.lock()
|
||||
frame.cels.append(Cel.new(sprite, 1))
|
||||
|
@ -377,7 +380,7 @@ func handle_tools(current_mouse_button : int, current_action : int, mouse_pos :
|
|||
Global.selection_rectangle.polygon[2] = end_pos
|
||||
Global.selection_rectangle.polygon[3] = Vector2(start_pos.x, end_pos.y)
|
||||
Global.Tools.COLORPICKER:
|
||||
var canvas_rect := Rect2(location, size)
|
||||
var canvas_rect := Rect2(location, Global.current_project.size)
|
||||
if can_handle && canvas_rect.has_point(mouse_pos):
|
||||
var image_data := Image.new()
|
||||
image_data.copy_from(sprite)
|
||||
|
@ -505,6 +508,7 @@ func onion_skinning() -> void:
|
|||
|
||||
|
||||
func draw_grid(grid_type : int) -> void:
|
||||
var size : Vector2 = Global.current_project.size
|
||||
if grid_type == Global.Grid_Types.CARTESIAN || grid_type == Global.Grid_Types.ALL:
|
||||
for x in range(Global.grid_width, size.x, Global.grid_width):
|
||||
draw_line(Vector2(x, location.y), Vector2(x, size.y), Global.grid_color, true)
|
||||
|
|
|
@ -3,7 +3,7 @@ class_name Project extends Reference
|
|||
|
||||
|
||||
var name := ""
|
||||
#var size : Vector2
|
||||
var size : Vector2
|
||||
var undo_redo : UndoRedo
|
||||
var undos := 0 # The number of times we added undo properties
|
||||
var has_changed := false
|
||||
|
@ -21,10 +21,11 @@ var brush_textures := [ImageTexture.new(), ImageTexture.new()]
|
|||
var selected_pixels := []
|
||||
|
||||
|
||||
func _init() -> void:
|
||||
undo_redo = UndoRedo.new()
|
||||
name = tr("untitled")
|
||||
func _init(_name := tr("untitled"), _size := Vector2(64, 64)) -> void:
|
||||
name = _name
|
||||
size = _size
|
||||
layers.append(Layer.new())
|
||||
undo_redo = UndoRedo.new()
|
||||
|
||||
|
||||
func frames_changed(value : Array) -> void:
|
||||
|
|
|
@ -422,7 +422,7 @@ func crop_image() -> void:
|
|||
var height := used_rect.size.y
|
||||
Global.current_project.undos += 1
|
||||
Global.current_project.undo_redo.create_action("Scale")
|
||||
Global.current_project.undo_redo.add_do_property(Global.canvas, "size", Vector2(width, height).floor())
|
||||
Global.current_project.undo_redo.add_do_property(Global.current_project, "size", Vector2(width, height).floor())
|
||||
for f in Global.current_project.frames:
|
||||
# Loop through all the layers to crop them
|
||||
for j in range(Global.current_project.layers.size() - 1, -1, -1):
|
||||
|
@ -430,7 +430,7 @@ func crop_image() -> void:
|
|||
Global.current_project.undo_redo.add_do_property(f.cels[j].image, "data", sprite.data)
|
||||
Global.current_project.undo_redo.add_undo_property(f.cels[j].image, "data", f.cels[j].image.data)
|
||||
|
||||
Global.current_project.undo_redo.add_undo_property(Global.canvas, "size", Global.canvas.size)
|
||||
Global.current_project.undo_redo.add_undo_property(Global.current_project, "size", Global.current_project.size)
|
||||
Global.current_project.undo_redo.add_undo_method(Global, "undo")
|
||||
Global.current_project.undo_redo.add_do_method(Global, "redo")
|
||||
Global.current_project.undo_redo.commit_action()
|
||||
|
|
|
@ -55,7 +55,7 @@ func _process(_delta : float) -> void:
|
|||
img.lock()
|
||||
for i in range(Global.current_project.selected_pixels.size()):
|
||||
var curr_px = Global.current_project.selected_pixels[i]
|
||||
if point_in_rectangle(curr_px, Global.canvas.location - Vector2.ONE, Global.canvas.size):
|
||||
if point_in_rectangle(curr_px, Global.canvas.location - Vector2.ONE, Global.current_project.size):
|
||||
orig_colors.append(layer.get_pixelv(curr_px)) # Color of pixel
|
||||
var px = curr_px - Global.current_project.selected_pixels[0]
|
||||
img.set_pixelv(px, orig_colors[i])
|
||||
|
@ -91,7 +91,7 @@ func _process(_delta : float) -> void:
|
|||
for i in range(orig_colors.size()):
|
||||
if orig_colors[i].a > 0:
|
||||
var px = polygon[0] + Global.current_project.selected_pixels[i] - Global.current_project.selected_pixels[0]
|
||||
if point_in_rectangle(px, Global.canvas.location - Vector2.ONE, Global.canvas.size):
|
||||
if point_in_rectangle(px, Global.canvas.location - Vector2.ONE, Global.current_project.size):
|
||||
layer.set_pixelv(px, orig_colors[i])
|
||||
Global.canvas.update_texture(current_layer_index)
|
||||
img.fill(Color(0, 0, 0, 0))
|
||||
|
@ -135,7 +135,7 @@ func _process(_delta : float) -> void:
|
|||
Global.canvas.handle_undo("Draw")
|
||||
for xx in range(start_pos.x, end_pos.x):
|
||||
for yy in range(start_pos.y, end_pos.y):
|
||||
if point_in_rectangle(Vector2(xx, yy), Global.canvas.location - Vector2.ONE, Global.canvas.location + Global.canvas.size):
|
||||
if point_in_rectangle(Vector2(xx, yy), Global.canvas.location - Vector2.ONE, Global.canvas.location + Global.current_project.size):
|
||||
layer.set_pixel(xx, yy, Color(0, 0, 0, 0))
|
||||
Global.canvas.handle_redo("Draw")
|
||||
|
||||
|
|
|
@ -38,12 +38,12 @@ func _on_ColorDefaults_pressed() -> void:
|
|||
|
||||
|
||||
func _on_FitToFrameButton_pressed() -> void:
|
||||
Global.camera.fit_to_frame(Global.canvas.size)
|
||||
Global.camera.fit_to_frame(Global.current_project.size)
|
||||
|
||||
|
||||
func _on_100ZoomButton_pressed() -> void:
|
||||
Global.camera.zoom = Vector2.ONE
|
||||
Global.camera.offset = Global.canvas.size / 2
|
||||
Global.camera.offset = Global.current_project.size / 2
|
||||
Global.zoom_level_label.text = str(round(100 / Global.camera.zoom.x)) + " %"
|
||||
Global.horizontal_ruler.update()
|
||||
Global.vertical_ruler.update()
|
||||
|
|
|
@ -76,7 +76,7 @@ func _on_CreateNewImage_confirmed() -> void:
|
|||
Global.clear_frames()
|
||||
Global.current_project.layers.clear()
|
||||
Global.current_project.layers.append(Layer.new())
|
||||
Global.canvas.size = Vector2(width, height).floor()
|
||||
Global.current_project.size = Vector2(width, height).floor()
|
||||
Global.canvas.fill_color = fill_color
|
||||
var frame : Frame = Global.canvas.new_empty_frame()
|
||||
Global.canvas.camera_zoom()
|
||||
|
|
|
@ -137,7 +137,7 @@ func external_export() -> void:
|
|||
func process_frame() -> void:
|
||||
var frame = Global.current_project.frames[frame_number - 1]
|
||||
var image := Image.new()
|
||||
image.create(Global.canvas.size.x, Global.canvas.size.y, false, Image.FORMAT_RGBA8)
|
||||
image.create(Global.current_project.size.x, Global.current_project.size.y, false, Image.FORMAT_RGBA8)
|
||||
blend_layers(image, frame)
|
||||
processed_images.clear()
|
||||
processed_images.append(image)
|
||||
|
@ -160,8 +160,8 @@ func process_spritesheet() -> void:
|
|||
var spritesheet_columns = lines_count if orientation == Orientation.ROWS else frames_divided_by_spritesheet_lines()
|
||||
var spritesheet_rows = lines_count if orientation == Orientation.COLUMNS else frames_divided_by_spritesheet_lines()
|
||||
|
||||
var width = Global.canvas.size.x * spritesheet_columns
|
||||
var height = Global.canvas.size.y * spritesheet_rows
|
||||
var width = Global.current_project.size.x * spritesheet_columns
|
||||
var height = Global.current_project.size.y * spritesheet_rows
|
||||
|
||||
var whole_image := Image.new()
|
||||
whole_image.create(width, height, false, Image.FORMAT_RGBA8)
|
||||
|
@ -173,22 +173,22 @@ func process_spritesheet() -> void:
|
|||
for frame in frames:
|
||||
if orientation == Orientation.ROWS:
|
||||
if vv < spritesheet_columns:
|
||||
origin.x = Global.canvas.size.x * vv
|
||||
origin.x = Global.current_project.size.x * vv
|
||||
vv += 1
|
||||
else:
|
||||
hh += 1
|
||||
origin.x = 0
|
||||
vv = 1
|
||||
origin.y = Global.canvas.size.y * hh
|
||||
origin.y = Global.current_project.size.y * hh
|
||||
else:
|
||||
if hh < spritesheet_rows:
|
||||
origin.y = Global.canvas.size.y * hh
|
||||
origin.y = Global.current_project.size.y * hh
|
||||
hh += 1
|
||||
else:
|
||||
vv += 1
|
||||
origin.y = 0
|
||||
hh = 1
|
||||
origin.x = Global.canvas.size.x * vv
|
||||
origin.x = Global.current_project.size.x * vv
|
||||
blend_layers(whole_image, frame, origin)
|
||||
|
||||
processed_images.clear()
|
||||
|
@ -199,7 +199,7 @@ func process_animation() -> void:
|
|||
processed_images.clear()
|
||||
for frame in Global.current_project.frames:
|
||||
var image := Image.new()
|
||||
image.create(Global.canvas.size.x, Global.canvas.size.y, false, Image.FORMAT_RGBA8)
|
||||
image.create(Global.current_project.size.x, Global.current_project.size.y, false, Image.FORMAT_RGBA8)
|
||||
blend_layers(image, frame)
|
||||
processed_images.append(image)
|
||||
|
||||
|
@ -375,7 +375,7 @@ func blend_layers(image : Image, frame : Frame, origin : Vector2 = Vector2(0, 0)
|
|||
var pixel_color := cel_image.get_pixel(xx, yy)
|
||||
var alpha : float = pixel_color.a * cel.opacity
|
||||
cel_image.set_pixel(xx, yy, Color(pixel_color.r, pixel_color.g, pixel_color.b, alpha))
|
||||
DrawingAlgos.blend_rect(image, cel_image, Rect2(Global.canvas.location, Global.canvas.size), origin)
|
||||
DrawingAlgos.blend_rect(image, cel_image, Rect2(Global.canvas.location, Global.current_project.size), origin)
|
||||
layer_i += 1
|
||||
image.unlock()
|
||||
|
||||
|
|
|
@ -55,7 +55,7 @@ func _on_ImportSprites_files_selected(paths : PoolStringArray) -> void:
|
|||
Global.dialog_open(true)
|
||||
continue
|
||||
|
||||
Global.canvas.size = image.get_size()
|
||||
Global.current_project.size = image.get_size()
|
||||
var frame := Frame.new()
|
||||
image.convert(Image.FORMAT_RGBA8)
|
||||
image.lock()
|
||||
|
@ -63,7 +63,7 @@ func _on_ImportSprites_files_selected(paths : PoolStringArray) -> void:
|
|||
|
||||
for _i in range(1, Global.current_project.layers.size()):
|
||||
var empty_sprite := Image.new()
|
||||
empty_sprite.create(Global.canvas.size.x, Global.canvas.size.y, false, Image.FORMAT_RGBA8)
|
||||
empty_sprite.create(Global.current_project.size.x, Global.current_project.size.y, false, Image.FORMAT_RGBA8)
|
||||
empty_sprite.fill(Color(0, 0, 0, 0))
|
||||
empty_sprite.lock()
|
||||
frame.cels.append(Cel.new(empty_sprite, 1))
|
||||
|
@ -91,14 +91,14 @@ func _on_ImportSprites_files_selected(paths : PoolStringArray) -> void:
|
|||
var frame := Frame.new()
|
||||
var cropped_image := Image.new()
|
||||
cropped_image = image.get_rect(Rect2(frame_width * xx, frame_height * yy, frame_width, frame_height))
|
||||
Global.canvas.size = cropped_image.get_size()
|
||||
Global.current_project.size = cropped_image.get_size()
|
||||
cropped_image.convert(Image.FORMAT_RGBA8)
|
||||
cropped_image.lock()
|
||||
frame.cels.append(Cel.new(cropped_image, 1))
|
||||
|
||||
for _i in range(1, Global.current_project.layers.size()):
|
||||
var empty_sprite := Image.new()
|
||||
empty_sprite.create(Global.canvas.size.x, Global.canvas.size.y, false, Image.FORMAT_RGBA8)
|
||||
empty_sprite.create(Global.current_project.size.x, Global.current_project.size.y, false, Image.FORMAT_RGBA8)
|
||||
empty_sprite.fill(Color(0, 0, 0, 0))
|
||||
empty_sprite.lock()
|
||||
frame.cels.append(Cel.new(empty_sprite, 1))
|
||||
|
|
|
@ -30,13 +30,13 @@ func _on_OutlineDialog_confirmed() -> void:
|
|||
var outline_pos : Vector2 = pos + Vector2.LEFT # Left
|
||||
if outline_pos.x < 0 || image.get_pixelv(outline_pos).a == 0:
|
||||
var new_pos : Vector2 = pos + Vector2.RIGHT * (i - 1)
|
||||
if new_pos.x < Global.canvas.size.x:
|
||||
if new_pos.x < Global.current_project.size.x:
|
||||
var new_pixel = image.get_pixelv(new_pos)
|
||||
if new_pixel.a > 0:
|
||||
new_image.set_pixelv(new_pos, outline_color)
|
||||
|
||||
outline_pos = pos + Vector2.RIGHT # Right
|
||||
if outline_pos.x >= Global.canvas.size.x || image.get_pixelv(outline_pos).a == 0:
|
||||
if outline_pos.x >= Global.current_project.size.x || image.get_pixelv(outline_pos).a == 0:
|
||||
var new_pos : Vector2 = pos + Vector2.LEFT * (i - 1)
|
||||
if new_pos.x >= 0:
|
||||
var new_pixel = image.get_pixelv(new_pos)
|
||||
|
@ -46,13 +46,13 @@ func _on_OutlineDialog_confirmed() -> void:
|
|||
outline_pos = pos + Vector2.UP # Up
|
||||
if outline_pos.y < 0 || image.get_pixelv(outline_pos).a == 0:
|
||||
var new_pos : Vector2 = pos + Vector2.DOWN * (i - 1)
|
||||
if new_pos.y < Global.canvas.size.y:
|
||||
if new_pos.y < Global.current_project.size.y:
|
||||
var new_pixel = image.get_pixelv(new_pos)
|
||||
if new_pixel.a > 0:
|
||||
new_image.set_pixelv(new_pos, outline_color)
|
||||
|
||||
outline_pos = pos + Vector2.DOWN # Down
|
||||
if outline_pos.y >= Global.canvas.size.y || image.get_pixelv(outline_pos).a == 0:
|
||||
if outline_pos.y >= Global.current_project.size.y || image.get_pixelv(outline_pos).a == 0:
|
||||
var new_pos : Vector2 = pos + Vector2.UP * (i - 1)
|
||||
if new_pos.y >= 0:
|
||||
var new_pixel = image.get_pixelv(new_pos)
|
||||
|
@ -63,29 +63,29 @@ func _on_OutlineDialog_confirmed() -> void:
|
|||
outline_pos = pos + (Vector2.LEFT + Vector2.UP) # Top left
|
||||
if (outline_pos.x < 0 && outline_pos.y < 0) || image.get_pixelv(outline_pos).a == 0:
|
||||
var new_pos : Vector2 = pos + (Vector2.RIGHT + Vector2.DOWN) * (i - 1)
|
||||
if new_pos.x < Global.canvas.size.x && new_pos.y < Global.canvas.size.y:
|
||||
if new_pos.x < Global.current_project.size.x && new_pos.y < Global.current_project.size.y:
|
||||
var new_pixel = image.get_pixelv(new_pos)
|
||||
if new_pixel.a > 0:
|
||||
new_image.set_pixelv(new_pos, outline_color)
|
||||
|
||||
outline_pos = pos + (Vector2.LEFT + Vector2.DOWN) # Bottom left
|
||||
if (outline_pos.x < 0 && outline_pos.y >= Global.canvas.size.y) || image.get_pixelv(outline_pos).a == 0:
|
||||
if (outline_pos.x < 0 && outline_pos.y >= Global.current_project.size.y) || image.get_pixelv(outline_pos).a == 0:
|
||||
var new_pos : Vector2 = pos + (Vector2.RIGHT + Vector2.UP) * (i - 1)
|
||||
if new_pos.x < Global.canvas.size.x && new_pos.y >= 0:
|
||||
if new_pos.x < Global.current_project.size.x && new_pos.y >= 0:
|
||||
var new_pixel = image.get_pixelv(new_pos)
|
||||
if new_pixel.a > 0:
|
||||
new_image.set_pixelv(new_pos, outline_color)
|
||||
|
||||
outline_pos = pos + (Vector2.RIGHT + Vector2.UP) # Top right
|
||||
if (outline_pos.x >= Global.canvas.size.x && outline_pos.y < 0) || image.get_pixelv(outline_pos).a == 0:
|
||||
if (outline_pos.x >= Global.current_project.size.x && outline_pos.y < 0) || image.get_pixelv(outline_pos).a == 0:
|
||||
var new_pos : Vector2 = pos + (Vector2.LEFT + Vector2.DOWN) * (i - 1)
|
||||
if new_pos.x >= 0 && new_pos.y < Global.canvas.size.y:
|
||||
if new_pos.x >= 0 && new_pos.y < Global.current_project.size.y:
|
||||
var new_pixel = image.get_pixelv(new_pos)
|
||||
if new_pixel.a > 0:
|
||||
new_image.set_pixelv(new_pos, outline_color)
|
||||
|
||||
outline_pos = pos + (Vector2.RIGHT + Vector2.DOWN) # Bottom right
|
||||
if (outline_pos.x >= Global.canvas.size.x && outline_pos.y >= Global.canvas.size.y) || image.get_pixelv(outline_pos).a == 0:
|
||||
if (outline_pos.x >= Global.current_project.size.x && outline_pos.y >= Global.current_project.size.y) || image.get_pixelv(outline_pos).a == 0:
|
||||
var new_pos : Vector2 = pos + (Vector2.LEFT + Vector2.UP) * (i - 1)
|
||||
if new_pos.x >= 0 && new_pos.y >= 0:
|
||||
var new_pixel = image.get_pixelv(new_pos)
|
||||
|
@ -100,7 +100,7 @@ func _on_OutlineDialog_confirmed() -> void:
|
|||
new_image.set_pixelv(new_pos, outline_color)
|
||||
|
||||
new_pos = pos + Vector2.RIGHT * i # Right
|
||||
if new_pos.x < Global.canvas.size.x:
|
||||
if new_pos.x < Global.current_project.size.x:
|
||||
var new_pixel = image.get_pixelv(new_pos)
|
||||
if new_pixel.a == 0:
|
||||
new_image.set_pixelv(new_pos, outline_color)
|
||||
|
@ -112,7 +112,7 @@ func _on_OutlineDialog_confirmed() -> void:
|
|||
new_image.set_pixelv(new_pos, outline_color)
|
||||
|
||||
new_pos = pos + Vector2.DOWN * i # Down
|
||||
if new_pos.y < Global.canvas.size.y:
|
||||
if new_pos.y < Global.current_project.size.y:
|
||||
var new_pixel = image.get_pixelv(new_pos)
|
||||
if new_pixel.a == 0:
|
||||
new_image.set_pixelv(new_pos, outline_color)
|
||||
|
@ -125,19 +125,19 @@ func _on_OutlineDialog_confirmed() -> void:
|
|||
new_image.set_pixelv(new_pos, outline_color)
|
||||
|
||||
new_pos = pos + (Vector2.LEFT + Vector2.DOWN) * i # Bottom left
|
||||
if new_pos.x >= 0 && new_pos.y < Global.canvas.size.y:
|
||||
if new_pos.x >= 0 && new_pos.y < Global.current_project.size.y:
|
||||
var new_pixel = image.get_pixelv(new_pos)
|
||||
if new_pixel.a == 0:
|
||||
new_image.set_pixelv(new_pos, outline_color)
|
||||
|
||||
new_pos = pos + (Vector2.RIGHT + Vector2.UP) * i # Top right
|
||||
if new_pos.x < Global.canvas.size.x && new_pos.y >= 0:
|
||||
if new_pos.x < Global.current_project.size.x && new_pos.y >= 0:
|
||||
var new_pixel = image.get_pixelv(new_pos)
|
||||
if new_pixel.a == 0:
|
||||
new_image.set_pixelv(new_pos, outline_color)
|
||||
|
||||
new_pos = pos + (Vector2.RIGHT + Vector2.DOWN) * i # Bottom right
|
||||
if new_pos.x < Global.canvas.size.x && new_pos.y < Global.canvas.size.y:
|
||||
if new_pos.x < Global.current_project.size.x && new_pos.y < Global.current_project.size.y:
|
||||
var new_pixel = image.get_pixelv(new_pos)
|
||||
if new_pixel.a == 0:
|
||||
new_image.set_pixelv(new_pos, outline_color)
|
||||
|
|
|
@ -7,7 +7,7 @@ func _on_ScaleImage_confirmed() -> void:
|
|||
var interpolation : int = $VBoxContainer/OptionsContainer/InterpolationType.selected
|
||||
Global.current_project.undos += 1
|
||||
Global.current_project.undo_redo.create_action("Scale")
|
||||
Global.current_project.undo_redo.add_do_property(Global.canvas, "size", Vector2(width, height).floor())
|
||||
Global.current_project.undo_redo.add_do_property(Global.current_project, "size", Vector2(width, height).floor())
|
||||
|
||||
for f in Global.current_project.frames:
|
||||
for i in range(f.cels.size() - 1, -1, -1):
|
||||
|
@ -17,7 +17,7 @@ func _on_ScaleImage_confirmed() -> void:
|
|||
Global.current_project.undo_redo.add_do_property(f.cels[i].image, "data", sprite.data)
|
||||
Global.current_project.undo_redo.add_undo_property(f.cels[i].image, "data", f.cels[i].image.data)
|
||||
|
||||
Global.current_project.undo_redo.add_undo_property(Global.canvas, "size", Global.canvas.size)
|
||||
Global.current_project.undo_redo.add_undo_property(Global.current_project, "size", Global.current_project.size)
|
||||
Global.current_project.undo_redo.add_undo_method(Global, "undo")
|
||||
Global.current_project.undo_redo.add_do_method(Global, "redo")
|
||||
Global.current_project.undo_redo.commit_action()
|
||||
|
|
|
@ -27,7 +27,7 @@ func _input(_event : InputEvent):
|
|||
point0.x -= width * 3
|
||||
point1.x += width * 3
|
||||
if Global.can_draw and Global.has_focus and point_in_rectangle(mouse_pos, point0, point1) and Input.is_action_just_pressed("left_mouse"):
|
||||
if !point_in_rectangle(Global.canvas.current_pixel, Global.canvas.location, Global.canvas.location + Global.canvas.size):
|
||||
if !point_in_rectangle(Global.canvas.current_pixel, Global.canvas.location, Global.canvas.location + Global.current_project.size):
|
||||
has_focus = true
|
||||
Global.has_focus = false
|
||||
update()
|
||||
|
@ -62,11 +62,11 @@ func _draw() -> void:
|
|||
|
||||
func outside_canvas() -> bool:
|
||||
if type == Types.HORIZONTAL:
|
||||
if points[0].y < 0 || points[0].y > Global.canvas.size.y:
|
||||
if points[0].y < 0 || points[0].y > Global.current_project.size.y:
|
||||
queue_free()
|
||||
return true
|
||||
else:
|
||||
if points[0].x < 0 || points[0].x > Global.canvas.size.x:
|
||||
if points[0].x < 0 || points[0].x > Global.current_project.size.x:
|
||||
queue_free()
|
||||
return true
|
||||
return false
|
||||
|
|
|
@ -341,7 +341,7 @@ func add_layer(is_new := true) -> void:
|
|||
for f in Global.current_project.frames:
|
||||
var new_layer := Image.new()
|
||||
if is_new:
|
||||
new_layer.create(Global.canvas.size.x, Global.canvas.size.y, false, Image.FORMAT_RGBA8)
|
||||
new_layer.create(Global.current_project.size.x, Global.current_project.size.y, false, Image.FORMAT_RGBA8)
|
||||
else: # Clone layer
|
||||
new_layer.copy_from(f.cels[Global.current_project.current_layer].image)
|
||||
|
||||
|
@ -440,7 +440,7 @@ func _on_MergeDownLayer_pressed() -> void:
|
|||
var new_layer := Image.new()
|
||||
new_layer.copy_from(f.cels[Global.current_project.current_layer - 1].image)
|
||||
new_layer.lock()
|
||||
DrawingAlgos.blend_rect(new_layer, selected_layer, Rect2(Global.canvas.location, Global.canvas.size), Vector2.ZERO)
|
||||
DrawingAlgos.blend_rect(new_layer, selected_layer, Rect2(Global.canvas.location, Global.current_project.size), Vector2.ZERO)
|
||||
new_cels.remove(Global.current_project.current_layer)
|
||||
if !selected_layer.is_invisible() and Global.current_project.layers[Global.current_project.current_layer - 1].linked_cels.size() > 1 and (f in Global.current_project.layers[Global.current_project.current_layer - 1].linked_cels):
|
||||
new_layers[Global.current_project.current_layer - 1].linked_cels.erase(f)
|
||||
|
|
|
@ -2,7 +2,7 @@ extends ColorRect
|
|||
|
||||
|
||||
func _ready() -> void:
|
||||
rect_size = Global.canvas.size
|
||||
rect_size = Global.current_project.size
|
||||
material.set_shader_param("size", Global.checker_size)
|
||||
material.set_shader_param("color1", Global.checker_color_1)
|
||||
material.set_shader_param("color2", Global.checker_color_2)
|
||||
|
|
Loading…
Reference in a new issue