mirror of
https://github.com/tonytins/CozyPixelStudio.git
synced 2025-05-07 11:34:48 -04:00
Basic text tool
This commit is contained in:
parent
3ec5ff4f41
commit
34804e6fc5
17 changed files with 281 additions and 4 deletions
BIN
assets/graphics/cursor_icons/text_cursor.png
Normal file
BIN
assets/graphics/cursor_icons/text_cursor.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 220 B |
13
assets/graphics/cursor_icons/text_cursor.png.import
Normal file
13
assets/graphics/cursor_icons/text_cursor.png.import
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
[remap]
|
||||||
|
|
||||||
|
importer="image"
|
||||||
|
type="Image"
|
||||||
|
path="res://.import/text_cursor.png-46628cf6392befd7350cadc065719d3b.image"
|
||||||
|
|
||||||
|
[deps]
|
||||||
|
|
||||||
|
source_file="res://assets/graphics/cursor_icons/text_cursor.png"
|
||||||
|
dest_files=[ "res://.import/text_cursor.png-46628cf6392befd7350cadc065719d3b.image" ]
|
||||||
|
|
||||||
|
[params]
|
||||||
|
|
BIN
assets/graphics/dark_themes/tools/text.png
Normal file
BIN
assets/graphics/dark_themes/tools/text.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 220 B |
34
assets/graphics/dark_themes/tools/text.png.import
Normal file
34
assets/graphics/dark_themes/tools/text.png.import
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
[remap]
|
||||||
|
|
||||||
|
importer="texture"
|
||||||
|
type="StreamTexture"
|
||||||
|
path="res://.import/text.png-970021a1171658bd56d4ae0c23768972.stex"
|
||||||
|
metadata={
|
||||||
|
"vram_texture": false
|
||||||
|
}
|
||||||
|
|
||||||
|
[deps]
|
||||||
|
|
||||||
|
source_file="res://assets/graphics/dark_themes/tools/text.png"
|
||||||
|
dest_files=[ "res://.import/text.png-970021a1171658bd56d4ae0c23768972.stex" ]
|
||||||
|
|
||||||
|
[params]
|
||||||
|
|
||||||
|
compress/mode=0
|
||||||
|
compress/lossy_quality=0.7
|
||||||
|
compress/hdr_mode=0
|
||||||
|
compress/bptc_ldr=0
|
||||||
|
compress/normal_map=0
|
||||||
|
flags/repeat=0
|
||||||
|
flags/filter=false
|
||||||
|
flags/mipmaps=false
|
||||||
|
flags/anisotropic=false
|
||||||
|
flags/srgb=2
|
||||||
|
process/fix_alpha_border=true
|
||||||
|
process/premult_alpha=false
|
||||||
|
process/HDR_as_SRGB=false
|
||||||
|
process/invert_color=false
|
||||||
|
stream=false
|
||||||
|
size_limit=0
|
||||||
|
detect_3d=true
|
||||||
|
svg/scale=1.0
|
BIN
assets/graphics/dark_themes/tools/text_l.png
Normal file
BIN
assets/graphics/dark_themes/tools/text_l.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 290 B |
34
assets/graphics/dark_themes/tools/text_l.png.import
Normal file
34
assets/graphics/dark_themes/tools/text_l.png.import
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
[remap]
|
||||||
|
|
||||||
|
importer="texture"
|
||||||
|
type="StreamTexture"
|
||||||
|
path="res://.import/text_l.png-7ef3f46f1090dd60537250c857fc87b7.stex"
|
||||||
|
metadata={
|
||||||
|
"vram_texture": false
|
||||||
|
}
|
||||||
|
|
||||||
|
[deps]
|
||||||
|
|
||||||
|
source_file="res://assets/graphics/dark_themes/tools/text_l.png"
|
||||||
|
dest_files=[ "res://.import/text_l.png-7ef3f46f1090dd60537250c857fc87b7.stex" ]
|
||||||
|
|
||||||
|
[params]
|
||||||
|
|
||||||
|
compress/mode=0
|
||||||
|
compress/lossy_quality=0.7
|
||||||
|
compress/hdr_mode=0
|
||||||
|
compress/bptc_ldr=0
|
||||||
|
compress/normal_map=0
|
||||||
|
flags/repeat=0
|
||||||
|
flags/filter=false
|
||||||
|
flags/mipmaps=false
|
||||||
|
flags/anisotropic=false
|
||||||
|
flags/srgb=2
|
||||||
|
process/fix_alpha_border=true
|
||||||
|
process/premult_alpha=false
|
||||||
|
process/HDR_as_SRGB=false
|
||||||
|
process/invert_color=false
|
||||||
|
stream=false
|
||||||
|
size_limit=0
|
||||||
|
detect_3d=true
|
||||||
|
svg/scale=1.0
|
BIN
assets/graphics/dark_themes/tools/text_l_r.png
Normal file
BIN
assets/graphics/dark_themes/tools/text_l_r.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 323 B |
34
assets/graphics/dark_themes/tools/text_l_r.png.import
Normal file
34
assets/graphics/dark_themes/tools/text_l_r.png.import
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
[remap]
|
||||||
|
|
||||||
|
importer="texture"
|
||||||
|
type="StreamTexture"
|
||||||
|
path="res://.import/text_l_r.png-68b397a3f5253ccd0fd06a2dbe44f205.stex"
|
||||||
|
metadata={
|
||||||
|
"vram_texture": false
|
||||||
|
}
|
||||||
|
|
||||||
|
[deps]
|
||||||
|
|
||||||
|
source_file="res://assets/graphics/dark_themes/tools/text_l_r.png"
|
||||||
|
dest_files=[ "res://.import/text_l_r.png-68b397a3f5253ccd0fd06a2dbe44f205.stex" ]
|
||||||
|
|
||||||
|
[params]
|
||||||
|
|
||||||
|
compress/mode=0
|
||||||
|
compress/lossy_quality=0.7
|
||||||
|
compress/hdr_mode=0
|
||||||
|
compress/bptc_ldr=0
|
||||||
|
compress/normal_map=0
|
||||||
|
flags/repeat=0
|
||||||
|
flags/filter=false
|
||||||
|
flags/mipmaps=false
|
||||||
|
flags/anisotropic=false
|
||||||
|
flags/srgb=2
|
||||||
|
process/fix_alpha_border=true
|
||||||
|
process/premult_alpha=false
|
||||||
|
process/HDR_as_SRGB=false
|
||||||
|
process/invert_color=false
|
||||||
|
stream=false
|
||||||
|
size_limit=0
|
||||||
|
detect_3d=true
|
||||||
|
svg/scale=1.0
|
BIN
assets/graphics/dark_themes/tools/text_r.png
Normal file
BIN
assets/graphics/dark_themes/tools/text_r.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 297 B |
34
assets/graphics/dark_themes/tools/text_r.png.import
Normal file
34
assets/graphics/dark_themes/tools/text_r.png.import
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
[remap]
|
||||||
|
|
||||||
|
importer="texture"
|
||||||
|
type="StreamTexture"
|
||||||
|
path="res://.import/text_r.png-9157efcaa46ca548897e2f232969466a.stex"
|
||||||
|
metadata={
|
||||||
|
"vram_texture": false
|
||||||
|
}
|
||||||
|
|
||||||
|
[deps]
|
||||||
|
|
||||||
|
source_file="res://assets/graphics/dark_themes/tools/text_r.png"
|
||||||
|
dest_files=[ "res://.import/text_r.png-9157efcaa46ca548897e2f232969466a.stex" ]
|
||||||
|
|
||||||
|
[params]
|
||||||
|
|
||||||
|
compress/mode=0
|
||||||
|
compress/lossy_quality=0.7
|
||||||
|
compress/hdr_mode=0
|
||||||
|
compress/bptc_ldr=0
|
||||||
|
compress/normal_map=0
|
||||||
|
flags/repeat=0
|
||||||
|
flags/filter=false
|
||||||
|
flags/mipmaps=false
|
||||||
|
flags/anisotropic=false
|
||||||
|
flags/srgb=2
|
||||||
|
process/fix_alpha_border=true
|
||||||
|
process/premult_alpha=false
|
||||||
|
process/HDR_as_SRGB=false
|
||||||
|
process/invert_color=false
|
||||||
|
stream=false
|
||||||
|
size_limit=0
|
||||||
|
detect_3d=true
|
||||||
|
svg/scale=1.0
|
|
@ -414,6 +414,16 @@ open_docs={
|
||||||
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":16777255,"unicode":0,"echo":false,"script":null)
|
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":16777255,"unicode":0,"echo":false,"script":null)
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
left_text_tool={
|
||||||
|
"deadzone": 0.5,
|
||||||
|
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":65,"unicode":0,"echo":false,"script":null)
|
||||||
|
]
|
||||||
|
}
|
||||||
|
right_text_tool={
|
||||||
|
"deadzone": 0.5,
|
||||||
|
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":true,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":65,"unicode":0,"echo":false,"script":null)
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
[locale]
|
[locale]
|
||||||
|
|
||||||
|
|
|
@ -46,6 +46,7 @@ var _tools = {
|
||||||
"Eraser" : "res://src/Tools/Eraser.tscn",
|
"Eraser" : "res://src/Tools/Eraser.tscn",
|
||||||
"Bucket" : "res://src/Tools/Bucket.tscn",
|
"Bucket" : "res://src/Tools/Bucket.tscn",
|
||||||
"LightenDarken" : "res://src/Tools/LightenDarken.tscn",
|
"LightenDarken" : "res://src/Tools/LightenDarken.tscn",
|
||||||
|
"Text" : "res://src/Tools/Text.tscn",
|
||||||
}
|
}
|
||||||
var _slots = {}
|
var _slots = {}
|
||||||
var _panels = {}
|
var _panels = {}
|
||||||
|
|
76
src/Tools/Text.gd
Normal file
76
src/Tools/Text.gd
Normal file
|
@ -0,0 +1,76 @@
|
||||||
|
extends "res://src/Tools/Base.gd"
|
||||||
|
|
||||||
|
|
||||||
|
var text_edit : TextEdit
|
||||||
|
var text_edit_pos := Vector2.ZERO
|
||||||
|
|
||||||
|
|
||||||
|
func _input(event : InputEvent) -> void:
|
||||||
|
if event.is_action_pressed("ui_accept"):
|
||||||
|
text_to_pixels()
|
||||||
|
|
||||||
|
|
||||||
|
func draw_start(position : Vector2) -> void:
|
||||||
|
if text_edit:
|
||||||
|
return
|
||||||
|
text_edit = TextEdit.new()
|
||||||
|
text_edit.text = ""
|
||||||
|
text_edit.rect_position = get_viewport().get_mouse_position()
|
||||||
|
text_edit_pos = position
|
||||||
|
text_edit.rect_min_size = Vector2(100, 60)
|
||||||
|
Global.control.add_child(text_edit)
|
||||||
|
|
||||||
|
|
||||||
|
func draw_move(_position : Vector2) -> void:
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
func draw_end(_position : Vector2) -> void:
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
func text_to_pixels() -> void:
|
||||||
|
if !text_edit:
|
||||||
|
return
|
||||||
|
var project : Project = Global.current_project
|
||||||
|
var size : Vector2 = project.size
|
||||||
|
var current_cel = project.frames[project.current_frame].cels[project.current_layer].image
|
||||||
|
var viewport_texture := Image.new()
|
||||||
|
|
||||||
|
var vp = VisualServer.viewport_create()
|
||||||
|
var canvas = VisualServer.canvas_create()
|
||||||
|
VisualServer.viewport_attach_canvas(vp, canvas)
|
||||||
|
VisualServer.viewport_set_size(vp, size.x, size.y)
|
||||||
|
VisualServer.viewport_set_disable_3d(vp, true)
|
||||||
|
VisualServer.viewport_set_usage(vp, VisualServer.VIEWPORT_USAGE_2D)
|
||||||
|
VisualServer.viewport_set_hdr(vp, true)
|
||||||
|
VisualServer.viewport_set_active(vp, true)
|
||||||
|
VisualServer.viewport_set_transparent_background(vp, true)
|
||||||
|
|
||||||
|
var ci_rid = VisualServer.canvas_item_create()
|
||||||
|
VisualServer.viewport_set_canvas_transform(vp, canvas, Transform())
|
||||||
|
VisualServer.canvas_item_set_parent(ci_rid, canvas)
|
||||||
|
var texture = ImageTexture.new()
|
||||||
|
texture.create_from_image(current_cel)
|
||||||
|
VisualServer.canvas_item_add_texture_rect(ci_rid, Rect2(Vector2(0, 0), size), texture)
|
||||||
|
var font : Font = load("res://assets/fonts/Roboto-Regular.tres")
|
||||||
|
font.draw(ci_rid, text_edit_pos, text_edit.text, tool_slot.color)
|
||||||
|
|
||||||
|
VisualServer.viewport_set_update_mode(vp, VisualServer.VIEWPORT_UPDATE_ONCE)
|
||||||
|
VisualServer.viewport_set_vflip(vp, true)
|
||||||
|
VisualServer.force_draw(false)
|
||||||
|
viewport_texture = VisualServer.texture_get_data(VisualServer.viewport_get_texture(vp))
|
||||||
|
VisualServer.free_rid(vp)
|
||||||
|
VisualServer.free_rid(canvas)
|
||||||
|
VisualServer.free_rid(ci_rid)
|
||||||
|
viewport_texture.convert(Image.FORMAT_RGBA8)
|
||||||
|
print(viewport_texture.get_size())
|
||||||
|
if !viewport_texture.is_empty():
|
||||||
|
Global.canvas.handle_undo("Draw")
|
||||||
|
current_cel.unlock()
|
||||||
|
current_cel.copy_from(viewport_texture)
|
||||||
|
current_cel.lock()
|
||||||
|
Global.canvas.handle_redo("Draw")
|
||||||
|
|
||||||
|
text_edit.queue_free()
|
||||||
|
text_edit = null
|
21
src/Tools/Text.tscn
Normal file
21
src/Tools/Text.tscn
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
[gd_scene load_steps=3 format=2]
|
||||||
|
|
||||||
|
[ext_resource path="res://src/Tools/Base.tscn" type="PackedScene" id=1]
|
||||||
|
[ext_resource path="res://src/Tools/Text.gd" type="Script" id=2]
|
||||||
|
|
||||||
|
|
||||||
|
[node name="ToolOptions" instance=ExtResource( 1 )]
|
||||||
|
script = ExtResource( 2 )
|
||||||
|
|
||||||
|
[node name="PixelPerfect" parent="." index="1"]
|
||||||
|
visible = false
|
||||||
|
|
||||||
|
[node name="EmptySpacer" parent="." index="2"]
|
||||||
|
visible = false
|
||||||
|
margin_top = 18.0
|
||||||
|
margin_bottom = 30.0
|
||||||
|
|
||||||
|
[node name="Mirror" parent="." index="3"]
|
||||||
|
visible = false
|
||||||
|
margin_top = 18.0
|
||||||
|
margin_bottom = 35.0
|
|
@ -70,8 +70,8 @@ resizable = true
|
||||||
mode = 0
|
mode = 0
|
||||||
access = 2
|
access = 2
|
||||||
filters = PoolStringArray( "*shader" )
|
filters = PoolStringArray( "*shader" )
|
||||||
current_dir = "/Users/manos/Dropbox/Orama Founding Members/εταιρικα αρχεια/Godot Projects/Pixelorama"
|
current_dir = "/Users/Overloaded/Documents/#Orama Stuff/Pixelorama/#Main Repos/Pixelorama"
|
||||||
current_path = "/Users/manos/Dropbox/Orama Founding Members/εταιρικα αρχεια/Godot Projects/Pixelorama/"
|
current_path = "/Users/Overloaded/Documents/#Orama Stuff/Pixelorama/#Main Repos/Pixelorama/"
|
||||||
[connection signal="about_to_show" from="." to="." method="_on_ShaderEffect_about_to_show"]
|
[connection signal="about_to_show" from="." to="." method="_on_ShaderEffect_about_to_show"]
|
||||||
[connection signal="confirmed" from="." to="." method="_on_ShaderEffect_confirmed"]
|
[connection signal="confirmed" from="." to="." method="_on_ShaderEffect_confirmed"]
|
||||||
[connection signal="popup_hide" from="." to="." method="_on_ShaderEffect_popup_hide"]
|
[connection signal="popup_hide" from="." to="." method="_on_ShaderEffect_popup_hide"]
|
||||||
|
|
|
@ -10,6 +10,7 @@ onready var tools := [
|
||||||
[$Eraser, "eraser"],
|
[$Eraser, "eraser"],
|
||||||
[$Bucket, "fill"],
|
[$Bucket, "fill"],
|
||||||
[$LightenDarken, "lightdark"],
|
[$LightenDarken, "lightdark"],
|
||||||
|
[$Text, "text"],
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
[gd_scene load_steps=23 format=2]
|
[gd_scene load_steps=24 format=2]
|
||||||
|
|
||||||
[ext_resource path="res://src/UI/ToolButtons.gd" type="Script" id=1]
|
[ext_resource path="res://src/UI/ToolButtons.gd" type="Script" id=1]
|
||||||
[ext_resource path="res://src/UI/Canvas/CanvasPreview.tscn" type="PackedScene" id=2]
|
[ext_resource path="res://src/UI/Canvas/CanvasPreview.tscn" type="PackedScene" id=2]
|
||||||
|
@ -8,6 +8,7 @@
|
||||||
[ext_resource path="res://src/UI/Canvas/Rulers/HorizontalRuler.gd" type="Script" id=6]
|
[ext_resource path="res://src/UI/Canvas/Rulers/HorizontalRuler.gd" type="Script" id=6]
|
||||||
[ext_resource path="res://src/UI/Canvas/CameraMovement.gd" type="Script" id=7]
|
[ext_resource path="res://src/UI/Canvas/CameraMovement.gd" type="Script" id=7]
|
||||||
[ext_resource path="res://src/SelectionRectangle.gd" type="Script" id=8]
|
[ext_resource path="res://src/SelectionRectangle.gd" type="Script" id=8]
|
||||||
|
[ext_resource path="res://assets/graphics/dark_themes/tools/text.png" type="Texture" id=9]
|
||||||
[ext_resource path="res://assets/graphics/dark_themes/tools/bucket.png" type="Texture" id=10]
|
[ext_resource path="res://assets/graphics/dark_themes/tools/bucket.png" type="Texture" id=10]
|
||||||
[ext_resource path="res://assets/graphics/dark_themes/tools/colorpicker.png" type="Texture" id=11]
|
[ext_resource path="res://assets/graphics/dark_themes/tools/colorpicker.png" type="Texture" id=11]
|
||||||
[ext_resource path="res://assets/graphics/dark_themes/tools/rectselect.png" type="Texture" id=12]
|
[ext_resource path="res://assets/graphics/dark_themes/tools/rectselect.png" type="Texture" id=12]
|
||||||
|
@ -58,7 +59,7 @@ __meta__ = {
|
||||||
margin_left = 7.0
|
margin_left = 7.0
|
||||||
margin_top = 7.0
|
margin_top = 7.0
|
||||||
margin_right = 39.0
|
margin_right = 39.0
|
||||||
margin_bottom = 255.0
|
margin_bottom = 291.0
|
||||||
script = ExtResource( 1 )
|
script = ExtResource( 1 )
|
||||||
__meta__ = {
|
__meta__ = {
|
||||||
"_edit_use_anchors_": false
|
"_edit_use_anchors_": false
|
||||||
|
@ -189,6 +190,24 @@ __meta__ = {
|
||||||
"_edit_use_anchors_": false
|
"_edit_use_anchors_": false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[node name="Text" type="Button" parent="ToolPanel/PanelContainer/ToolButtons" groups=[
|
||||||
|
"UIButtons",
|
||||||
|
]]
|
||||||
|
margin_top = 252.0
|
||||||
|
margin_right = 32.0
|
||||||
|
margin_bottom = 284.0
|
||||||
|
rect_min_size = Vector2( 32, 32 )
|
||||||
|
mouse_default_cursor_shape = 2
|
||||||
|
button_mask = 3
|
||||||
|
|
||||||
|
[node name="TextureRect" type="TextureRect" parent="ToolPanel/PanelContainer/ToolButtons/Text"]
|
||||||
|
margin_right = 32.0
|
||||||
|
margin_bottom = 32.0
|
||||||
|
texture = ExtResource( 9 )
|
||||||
|
__meta__ = {
|
||||||
|
"_edit_use_anchors_": false
|
||||||
|
}
|
||||||
|
|
||||||
[node name="CanvasAndTimeline" type="VSplitContainer" parent="."]
|
[node name="CanvasAndTimeline" type="VSplitContainer" parent="."]
|
||||||
margin_left = 48.0
|
margin_left = 48.0
|
||||||
margin_right = 950.0
|
margin_right = 950.0
|
||||||
|
|
Loading…
Add table
Reference in a new issue