mirror of
https://github.com/tonytins/CozyPixelStudio.git
synced 2025-12-15 23:34:43 -05:00
Fixed issue with open last image and turned off pixel perfect drawing by default
This commit is contained in:
parent
82fe186b65
commit
460f86ff8e
6 changed files with 49 additions and 49 deletions
|
|
@ -2,7 +2,7 @@ class Drawer:
|
|||
func reset() -> void:
|
||||
pass
|
||||
|
||||
func set_pixel(sprite: Image, pos: Vector2, new_color: Color) -> void:
|
||||
func set_pixel(_sprite: Image, _pos: Vector2, _new_color: Color) -> void:
|
||||
pass
|
||||
|
||||
|
||||
|
|
@ -10,8 +10,8 @@ class SimpleDrawer extends Drawer:
|
|||
func reset() -> void:
|
||||
pass
|
||||
|
||||
func set_pixel(sprite: Image, pos: Vector2, new_color: Color) -> void:
|
||||
sprite.set_pixel(pos.x, pos.y, new_color)
|
||||
func set_pixel(_sprite: Image, _pos: Vector2, _new_color: Color) -> void:
|
||||
_sprite.set_pixel(_pos.x, _pos.y, _new_color)
|
||||
|
||||
|
||||
class PixelPerfectDrawer extends Drawer:
|
||||
|
|
@ -22,9 +22,9 @@ class PixelPerfectDrawer extends Drawer:
|
|||
func reset():
|
||||
last_pixels = [null, null]
|
||||
|
||||
func set_pixel(sprite: Image, pos: Vector2, new_color: Color) -> void:
|
||||
last_pixels.push_back([pos, sprite.get_pixel(pos.x, pos.y)])
|
||||
sprite.set_pixel(pos.x, pos.y, new_color)
|
||||
func set_pixel(_sprite: Image, _pos: Vector2, _new_color: Color) -> void:
|
||||
last_pixels.push_back([_pos, _sprite.get_pixel(_pos.x, _pos.y)])
|
||||
_sprite.set_pixel(_pos.x, _pos.y, _new_color)
|
||||
|
||||
var corner = last_pixels.pop_front()
|
||||
var neighbour = last_pixels[0]
|
||||
|
|
@ -32,6 +32,6 @@ class PixelPerfectDrawer extends Drawer:
|
|||
if corner == null or neighbour == null:
|
||||
return
|
||||
|
||||
if pos - corner[0] in corners and pos - neighbour[0] in neighbours:
|
||||
sprite.set_pixel(neighbour[0].x, neighbour[0].y, neighbour[1])
|
||||
if _pos - corner[0] in corners and _pos - neighbour[0] in neighbours:
|
||||
_sprite.set_pixel(neighbour[0].x, neighbour[0].y, neighbour[1])
|
||||
last_pixels[0] = corner
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue