mirror of
https://github.com/tonytins/CozyPixelStudio.git
synced 2025-07-15 00:24:42 -04:00
Replaced the _min and _max Project variables with Project.selected_pixels
This will allow us to create more selection tools in the future, that aren't necessarily rectangular (See #129) and even enhance the current rectangle selection tool (See #56) Current issues spotted so far: Drawing is slower for large images, and bucket filling is also considerably slower even on a 64x64 image. Optimizations are required.
This commit is contained in:
parent
8c965c1858
commit
0f82be765e
10 changed files with 108 additions and 80 deletions
|
@ -28,6 +28,7 @@ func has_point(position : Vector2) -> bool:
|
|||
func get_rect() -> Rect2:
|
||||
return _selected_rect
|
||||
|
||||
|
||||
func set_rect(rect : Rect2) -> void:
|
||||
_selected_rect = rect
|
||||
polygon[0] = rect.position
|
||||
|
@ -36,6 +37,19 @@ func set_rect(rect : Rect2) -> void:
|
|||
polygon[3] = Vector2(rect.position.x, rect.end.y)
|
||||
visible = not rect.has_no_area()
|
||||
|
||||
var project : Project = Global.current_project
|
||||
if rect.has_no_area():
|
||||
project.select_all_pixels()
|
||||
else:
|
||||
project.clear_selection()
|
||||
for x in range(rect.position.x, rect.end.x):
|
||||
for y in range(rect.position.y, rect.end.y):
|
||||
if x < 0 or x >= project.size.x:
|
||||
continue
|
||||
if y < 0 or y >= project.size.y:
|
||||
continue
|
||||
project.selected_pixels.append(Vector2(x, y))
|
||||
|
||||
|
||||
func move_rect(move : Vector2) -> void:
|
||||
_selected_rect.position += move
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue