1
0
Fork 0
mirror of https://github.com/Orama-Interactive/Pixelorama.git synced 2025-01-31 07:29:49 +00:00

Remove unneeded location variables (#425)

Co-authored-by: kleonc <kleonc@users.noreply.github.com>
This commit is contained in:
kleonc 2021-01-06 16:11:50 +01:00 committed by GitHub
parent 1b8520c1a9
commit b1c0344d0b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 22 additions and 27 deletions

View file

@ -320,7 +320,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))
image.blend_rect(cel_image, Rect2(Global.canvas.location, Global.current_project.size), origin)
image.blend_rect(cel_image, Rect2(Vector2.ZERO, Global.current_project.size), origin)
cel_image.unlock()
layer_i += 1
image.unlock()

View file

@ -2,7 +2,6 @@ class_name Canvas
extends Node2D
var location := Vector2.ZERO
var fill_color := Color(0, 0, 0, 0)
var current_pixel := Vector2.ZERO
var can_undo := true
@ -40,7 +39,7 @@ func _draw() -> void:
for i in range(Global.current_project.layers.size()):
var modulate_color := Color(1, 1, 1, current_cels[i].opacity)
if Global.current_project.layers[i].visible: # if it's visible
draw_texture(current_cels[i].image_texture, location, modulate_color)
draw_texture(current_cels[i].image_texture, Vector2.ZERO, modulate_color)
if Global.onion_skinning:
onion_skinning()
@ -65,7 +64,7 @@ func _input(event : InputEvent) -> void:
# value when shrink parameter is not equal to one. At godot version 3.2.3
var tmp_transform = get_canvas_transform().affine_inverse()
var tmp_position = Global.main_viewport.get_local_mouse_position()
current_pixel = tmp_transform.basis_xform(tmp_position) + tmp_transform.origin + location
current_pixel = tmp_transform.basis_xform(tmp_position) + tmp_transform.origin
if Global.has_focus:
update()
@ -237,7 +236,7 @@ func onion_skinning() -> void:
for layer in Global.current_project.frames[Global.current_project.current_frame - i].cels:
if Global.current_project.layers[layer_i].visible:
color.a = 0.6 / i
draw_texture(layer.image_texture, location, color)
draw_texture(layer.image_texture, Vector2.ZERO, color)
layer_i += 1
# Future
@ -253,5 +252,5 @@ func onion_skinning() -> void:
for layer in Global.current_project.frames[Global.current_project.current_frame + i].cels:
if Global.current_project.layers[layer_i].visible:
color.a = 0.6 / i
draw_texture(layer.image_texture, location, color)
draw_texture(layer.image_texture, Vector2.ZERO, color)
layer_i += 1

View file

@ -1,7 +1,6 @@
extends Node2D
var location := Vector2.ZERO
var isometric_polylines := [] # An array of PoolVector2Arrays
@ -14,10 +13,10 @@ func draw_grid(grid_type : int) -> void:
var size : Vector2 = Global.transparent_checker.rect_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)
draw_line(Vector2(x, 0), Vector2(x, size.y), Global.grid_color, true)
for y in range(Global.grid_height, size.y, Global.grid_height):
draw_line(Vector2(location.x, y), Vector2(size.x, y), Global.grid_color, true)
draw_line(Vector2(0, y), Vector2(size.x, y), Global.grid_color, true)
if grid_type == Global.Grid_Types.ISOMETRIC || grid_type == Global.Grid_Types.ALL:
var i := 0

View file

@ -28,7 +28,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") and visible:
if !point_in_rectangle(Global.canvas.current_pixel, Global.canvas.location, Global.canvas.location + project.size):
if !point_in_rectangle(Global.canvas.current_pixel, Vector2.ZERO, project.size):
has_focus = true
Global.has_focus = false
update()

View file

@ -1,9 +1,6 @@
extends Node2D
var location := Vector2.ZERO
func _draw() -> void:
var size : Vector2 = Global.current_project.size
var positions : Array = get_tile_positions(size)
@ -28,24 +25,24 @@ func get_tile_positions(size):
match Global.current_project.tile_mode:
1:
return [
Vector2(location.x, location.y + size.y), # Down
Vector2(location.x - size.x, location.y + size.y), # Down left
Vector2(location.x - size.x, location.y), # Left
location - size, # Up left
Vector2(location.x, location.y - size.y), # Up
Vector2(location.x + size.x, location.y - size.y), # Up right
Vector2(location.x + size.x, location.y), # Right
location + size # Down right
Vector2(0, size.y), # Down
Vector2(-size.x, size.y), # Down left
Vector2(-size.x, 0), # Left
-size, # Up left
Vector2(0, -size.y), # Up
Vector2(size.x, -size.y), # Up right
Vector2(size.x, 0), # Right
size # Down right
]
2:
return [
Vector2(location.x + size.x, location.y), # Right
Vector2(location.x - size.x, location.y), # Left
Vector2(size.x, 0), # Right
Vector2(-size.x, 0), # Left
]
3:
return [
Vector2(location.x, location.y + size.y), # Down
Vector2(location.x, location.y - size.y), # Up
Vector2(0, size.y), # Down
Vector2(0, -size.y), # Up
]
_:
return []

View file

@ -31,7 +31,7 @@ func _on_ResizeCanvas_about_to_show() -> void:
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))
image.blend_rect(cel_image, Rect2(Global.canvas.location, Global.current_project.size), Vector2.ZERO)
image.blend_rect(cel_image, Rect2(Vector2.ZERO, Global.current_project.size), Vector2.ZERO)
layer_i += 1
image.unlock()

View file

@ -465,7 +465,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()
new_layer.blend_rect(selected_layer, Rect2(Global.canvas.location, Global.current_project.size), Vector2.ZERO)
new_layer.blend_rect(selected_layer, Rect2(Vector2.ZERO, 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)