mirror of
https://github.com/Orama-Interactive/Pixelorama.git
synced 2025-01-19 01:29:49 +00:00
Add some missing static typing
This commit is contained in:
parent
1c2f4c5350
commit
01f8273e4b
|
@ -2,7 +2,7 @@ extends BaseTool
|
|||
|
||||
var _brush := Brushes.get_default_brush()
|
||||
var _brush_size := 1
|
||||
var _cache_limit: int = 3
|
||||
var _cache_limit := 3
|
||||
var _brush_interpolate := 0
|
||||
var _brush_image := Image.new()
|
||||
var _brush_texture := ImageTexture.new()
|
||||
|
@ -96,8 +96,8 @@ func get_config() -> Dictionary:
|
|||
|
||||
|
||||
func set_config(config: Dictionary) -> void:
|
||||
var type = config.get("brush_type", _brush.type)
|
||||
var index = config.get("brush_index", _brush.index)
|
||||
var type: int = config.get("brush_type", _brush.type)
|
||||
var index: int = config.get("brush_index", _brush.index)
|
||||
_brush = Global.brushes_popup.get_brush(type, index)
|
||||
_brush_size = config.get("brush_size", _brush_size)
|
||||
_brush_interpolate = config.get("brush_interpolate", _brush_interpolate)
|
||||
|
@ -125,7 +125,7 @@ func update_brush() -> void:
|
|||
if _brush.random.size() <= 1:
|
||||
_brush_image = _create_blended_brush_image(_brush.image)
|
||||
else:
|
||||
var random = randi() % _brush.random.size()
|
||||
var random := randi() % _brush.random.size()
|
||||
_brush_image = _create_blended_brush_image(_brush.random[random])
|
||||
_brush_texture.create_from_image(_brush_image, 0)
|
||||
update_mirror_brush()
|
||||
|
@ -203,7 +203,7 @@ func commit_undo() -> void:
|
|||
|
||||
func draw_tool(position: Vector2) -> void:
|
||||
_prepare_tool()
|
||||
var coords_to_draw = _draw_tool(position)
|
||||
var coords_to_draw := _draw_tool(position)
|
||||
for coord in coords_to_draw:
|
||||
_set_pixel_no_cache(coord)
|
||||
|
||||
|
@ -233,10 +233,10 @@ func _prepare_tool() -> void:
|
|||
|
||||
func _prepare_circle_tool(fill: bool) -> void:
|
||||
_circle_tool_shortcut = PoolVector2Array()
|
||||
var circle_tool_map = _create_circle_indicator(_brush_size, fill)
|
||||
var circle_tool_map := _create_circle_indicator(_brush_size, fill)
|
||||
# Go through that BitMap and build an Array of the "displacement" from the center of the bits
|
||||
# that are true.
|
||||
var diameter = 2 * _brush_size + 1
|
||||
var diameter := _brush_size * 2 + 1
|
||||
for n in range(0, diameter):
|
||||
for m in range(0, diameter):
|
||||
if circle_tool_map.get_bit(Vector2(m, n)):
|
||||
|
@ -267,12 +267,12 @@ func draw_fill_gap(start: Vector2, end: Vector2) -> void:
|
|||
var dy := int(-abs(end.y - start.y))
|
||||
var err := dx + dy
|
||||
var e2 := err << 1
|
||||
var sx = 1 if start.x < end.x else -1
|
||||
var sy = 1 if start.y < end.y else -1
|
||||
var x = start.x
|
||||
var y = start.y
|
||||
var sx := 1 if start.x < end.x else -1
|
||||
var sy := 1 if start.y < end.y else -1
|
||||
var x := start.x
|
||||
var y := start.y
|
||||
_prepare_tool()
|
||||
var coords_to_draw = {}
|
||||
var coords_to_draw := {}
|
||||
while !(x == end.x && y == end.y):
|
||||
e2 = err << 1
|
||||
if e2 >= dy:
|
||||
|
@ -295,7 +295,7 @@ func draw_tool_pixel(position: Vector2) -> void:
|
|||
|
||||
# Compute the array of coordinates that should be drawn
|
||||
func _compute_draw_tool_pixel(position: Vector2) -> PoolVector2Array:
|
||||
var result = PoolVector2Array()
|
||||
var result := PoolVector2Array()
|
||||
var start := position - Vector2.ONE * (_brush_size >> 1)
|
||||
var end := start + Vector2.ONE * _brush_size
|
||||
for y in range(start.y, end.y):
|
||||
|
@ -315,7 +315,7 @@ func _compute_draw_tool_circle(position: Vector2, fill := false) -> PoolVector2A
|
|||
if _circle_tool_shortcut:
|
||||
return _draw_tool_circle_from_map(position)
|
||||
else:
|
||||
var result = PoolVector2Array()
|
||||
var result := PoolVector2Array()
|
||||
var r := _brush_size
|
||||
var x := -r
|
||||
var y := 0
|
||||
|
@ -343,7 +343,7 @@ func _compute_draw_tool_circle(position: Vector2, fill := false) -> PoolVector2A
|
|||
|
||||
|
||||
func _draw_tool_circle_from_map(position: Vector2) -> PoolVector2Array:
|
||||
var result = PoolVector2Array()
|
||||
var result := PoolVector2Array()
|
||||
for displacement in _circle_tool_shortcut:
|
||||
result.append(position + displacement)
|
||||
return result
|
||||
|
|
|
@ -5,9 +5,9 @@ signal brush_selected(brush)
|
|||
signal brush_removed(brush)
|
||||
enum { PIXEL, CIRCLE, FILLED_CIRCLE, FILE, RANDOM_FILE, CUSTOM }
|
||||
|
||||
var pixel_image = preload("res://assets/graphics/pixel_image.png")
|
||||
var circle_image = preload("res://assets/graphics/circle_9x9.png")
|
||||
var circle_filled_image = preload("res://assets/graphics/circle_filled_9x9.png")
|
||||
var pixel_image := preload("res://assets/graphics/pixel_image.png")
|
||||
var circle_image := preload("res://assets/graphics/circle_9x9.png")
|
||||
var circle_filled_image := preload("res://assets/graphics/circle_filled_9x9.png")
|
||||
|
||||
|
||||
class Brush:
|
||||
|
@ -18,8 +18,8 @@ class Brush:
|
|||
|
||||
|
||||
func _ready() -> void:
|
||||
var container = Global.brushes_popup.get_node("TabContainer/File/FileBrushContainer")
|
||||
var button = create_button(pixel_image)
|
||||
var container = get_node("TabContainer/File/FileBrushContainer")
|
||||
var button := create_button(pixel_image)
|
||||
button.brush.type = PIXEL
|
||||
button.hint_tooltip = "Pixel brush"
|
||||
container.add_child(button)
|
||||
|
@ -44,7 +44,7 @@ func select_brush(brush: Brush) -> void:
|
|||
|
||||
|
||||
static func get_default_brush() -> Brush:
|
||||
var brush = Brush.new()
|
||||
var brush := Brush.new()
|
||||
brush.type = PIXEL
|
||||
brush.index = 0
|
||||
return brush
|
||||
|
@ -60,7 +60,7 @@ static func create_button(image: Image) -> Node:
|
|||
|
||||
|
||||
static func add_file_brush(images: Array, hint := "") -> void:
|
||||
var button = create_button(images[0])
|
||||
var button := create_button(images[0])
|
||||
button.brush.type = FILE if images.size() == 1 else RANDOM_FILE
|
||||
button.brush.image = images[0]
|
||||
button.brush.random = images
|
||||
|
@ -71,7 +71,7 @@ static func add_file_brush(images: Array, hint := "") -> void:
|
|||
|
||||
|
||||
static func add_project_brush(image: Image, hint := "") -> void:
|
||||
var button = create_button(image)
|
||||
var button := create_button(image)
|
||||
button.brush.type = CUSTOM
|
||||
button.brush.image = image
|
||||
button.hint_tooltip = hint
|
||||
|
@ -90,10 +90,10 @@ static func clear_project_brush() -> void:
|
|||
func get_brush(type: int, index: int) -> Brush:
|
||||
var container
|
||||
if type == CUSTOM:
|
||||
container = Global.brushes_popup.get_node("TabContainer/Project/ProjectBrushContainer")
|
||||
container = get_node("TabContainer/Project/ProjectBrushContainer")
|
||||
else:
|
||||
container = Global.brushes_popup.get_node("TabContainer/File/FileBrushContainer")
|
||||
var brush = get_default_brush()
|
||||
container = get_node("TabContainer/File/FileBrushContainer")
|
||||
var brush := get_default_brush()
|
||||
if index < container.get_child_count():
|
||||
brush = container.get_child(index).brush
|
||||
return brush
|
||||
|
@ -103,7 +103,7 @@ func remove_brush(brush_button: Node) -> void:
|
|||
emit_signal("brush_removed", brush_button.brush)
|
||||
|
||||
var project = Global.current_project
|
||||
var undo_brushes = project.brushes.duplicate()
|
||||
var undo_brushes: Array = project.brushes.duplicate()
|
||||
project.brushes.erase(brush_button.brush.image)
|
||||
|
||||
project.undos += 1
|
||||
|
|
Loading…
Reference in a new issue