mirror of
https://github.com/Relintai/pandemonium_paint_experimental.git
synced 2024-11-07 16:52:10 +01:00
Initial draw implementation for the PaintCanvas. Also udpated the engine to get the required changes.
This commit is contained in:
parent
355378f4d5
commit
6ac6df6e7d
2
HEADS
2
HEADS
@ -1 +1 @@
|
||||
{"engine": {"3.2": "64a9e86c5c20bd4bd5833f0563457d0126617489", "3.x": "9b512dd510207d32911064a1bbe15b80c91b006b"}, "world_generator": {"master": "260c430f11b0b591eaf4714516419aa327d2842c"}, "entity_spell_system": {"master": "3536f01bacf5f54cefb32b768cd020a1f94d0ade"}, "ui_extensions": {"master": "80a3b96fc56991a0f88a1d441ed1e3cebaf3307a"}, "texture_packer": {"master": "ae4d222fbaade063ed6f0bc9f3aaa53df68a7fed"}, "fastnoise": {"master": "46bb1f610bfb7171613b5c708d312bcf94e89356"}, "thread_pool": {"master": "0917511d04bb1aa308385b63ec88d3c182990628"}, "mesh_data_resource": {"master": "a062d871d49d954c5466b9de54b4075cb61cbef4"}, "mesh_utils": {"master": "b52a261c31f04fad624e5cfbcdcc4a45d61136da"}, "props": {"master": "2afd6eff45f9a921bdf4090ff3029def86df5cb5"}, "terraman_2d": {"master": "60a7e84a5dc2fc252b0c582dd8f877685d28d74a"}, "broken_seals_module": {"master": "52c5a81350db1c29d375c63d95010260911ec034"}, "rtile_map": {"master": "389070cfef387b69902e23e6c4ac53997b69e42e"}, "props_2d": {"master": "a45822b63519d7f9fb391ab6b1dced468c6f399d"}, "pandemonium_engine": {"master": "ab3e6f00145a31c612e026da192d11e20bbb1d01"}}
|
||||
{"engine": {"3.2": "64a9e86c5c20bd4bd5833f0563457d0126617489", "3.x": "9b512dd510207d32911064a1bbe15b80c91b006b"}, "world_generator": {"master": "260c430f11b0b591eaf4714516419aa327d2842c"}, "entity_spell_system": {"master": "3536f01bacf5f54cefb32b768cd020a1f94d0ade"}, "ui_extensions": {"master": "80a3b96fc56991a0f88a1d441ed1e3cebaf3307a"}, "texture_packer": {"master": "ae4d222fbaade063ed6f0bc9f3aaa53df68a7fed"}, "fastnoise": {"master": "46bb1f610bfb7171613b5c708d312bcf94e89356"}, "thread_pool": {"master": "0917511d04bb1aa308385b63ec88d3c182990628"}, "mesh_data_resource": {"master": "a062d871d49d954c5466b9de54b4075cb61cbef4"}, "mesh_utils": {"master": "b52a261c31f04fad624e5cfbcdcc4a45d61136da"}, "props": {"master": "2afd6eff45f9a921bdf4090ff3029def86df5cb5"}, "terraman_2d": {"master": "60a7e84a5dc2fc252b0c582dd8f877685d28d74a"}, "broken_seals_module": {"master": "52c5a81350db1c29d375c63d95010260911ec034"}, "rtile_map": {"master": "389070cfef387b69902e23e6c4ac53997b69e42e"}, "props_2d": {"master": "a45822b63519d7f9fb391ab6b1dced468c6f399d"}, "pandemonium_engine": {"master": "afa0e83f780ceb7255f2c4b5a72b7ed20931f3c2"}}
|
@ -1,6 +1,50 @@
|
||||
tool
|
||||
extends PaintCanvas
|
||||
|
||||
var _mouse_down : bool = false
|
||||
|
||||
func draw(local_position : Vector2) -> void:
|
||||
set_pixel(local_position.x, local_position.y, Color(1, 1, 1, 1))
|
||||
|
||||
func is_local(var pos : Vector2) -> bool:
|
||||
if pos.x < 0 || pos.y < 0 || pos.x > size.x || pos.y > size.y:
|
||||
return false
|
||||
|
||||
return true
|
||||
|
||||
func forward_canvas_gui_input(event: InputEvent) -> bool:
|
||||
if event is InputEventMouseButton:
|
||||
if event.button_index != BUTTON_LEFT:
|
||||
return false
|
||||
|
||||
if _mouse_down:
|
||||
if !event.pressed:
|
||||
_mouse_down = false
|
||||
else:
|
||||
# This seems to be the easiest way to get local mouse position,
|
||||
# even though the event is available
|
||||
var local_position : Vector2 = get_local_mouse_position()
|
||||
|
||||
if is_local(local_position):
|
||||
_mouse_down = true
|
||||
return true
|
||||
|
||||
if _mouse_down && event is InputEventMouseMotion:
|
||||
var local_position : Vector2 = get_local_mouse_position()
|
||||
|
||||
if is_local(local_position):
|
||||
draw(local_position)
|
||||
update_textures()
|
||||
update()
|
||||
return true
|
||||
|
||||
return false
|
||||
|
||||
func _ready() -> void:
|
||||
#temp
|
||||
resize(1, 1)
|
||||
resize(128, 128)
|
||||
|
||||
func _draw() -> void:
|
||||
draw_texture(get_image_texture(), Vector2())
|
||||
draw_texture(get_preview_image_texture(), Vector2())
|
||||
|
@ -4,8 +4,10 @@
|
||||
[ext_resource path="res://PaintProject.gd" type="Script" id=2]
|
||||
|
||||
[node name="PaintProject" type="PaintProject"]
|
||||
current_color = Color( 0.957181, 0.325235, 0.352407, 1 )
|
||||
size = Vector2i( 128, 128 )
|
||||
current_color = Color( 0.86538, 0.233915, 0.49333, 1 )
|
||||
script = ExtResource( 2 )
|
||||
|
||||
[node name="PaintCanvas" type="PaintCanvas" parent="."]
|
||||
size = Vector2i( 128, 128 )
|
||||
script = ExtResource( 1 )
|
||||
|
Loading…
Reference in New Issue
Block a user