mirror of
https://github.com/Relintai/broken_seals_2d.git
synced 2024-11-11 20:35:10 +01:00
Added outline generation support, and color modulation to the simple sprite sheet generator, and re generated the spritesheet using it..
This commit is contained in:
parent
4b820f2370
commit
0cb52676f2
@ -2191,7 +2191,7 @@ region_enabled = true
|
|||||||
region_rect = Rect2( 27, 57, 14, 6 )
|
region_rect = Rect2( 27, 57, 14, 6 )
|
||||||
|
|
||||||
[node name="Torso" type="Sprite" parent="Hip"]
|
[node name="Torso" type="Sprite" parent="Hip"]
|
||||||
position = Vector2( 0, -2.16791 )
|
position = Vector2( 0, -2.24034 )
|
||||||
texture = ExtResource( 1 )
|
texture = ExtResource( 1 )
|
||||||
offset = Vector2( 0, -5 )
|
offset = Vector2( 0, -5 )
|
||||||
region_enabled = true
|
region_enabled = true
|
||||||
@ -2201,7 +2201,7 @@ __meta__ = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
[node name="leg_r" type="Sprite" parent="Hip/Torso"]
|
[node name="leg_r" type="Sprite" parent="Hip/Torso"]
|
||||||
position = Vector2( -2, 0.999999 )
|
position = Vector2( -2, 1 )
|
||||||
rotation = -0.0158546
|
rotation = -0.0158546
|
||||||
texture = ExtResource( 1 )
|
texture = ExtResource( 1 )
|
||||||
offset = Vector2( 0, 3 )
|
offset = Vector2( 0, 3 )
|
||||||
@ -2260,7 +2260,6 @@ __meta__ = {
|
|||||||
|
|
||||||
[node name="remote_arm_r" type="Sprite" parent="Hip/Torso"]
|
[node name="remote_arm_r" type="Sprite" parent="Hip/Torso"]
|
||||||
position = Vector2( -5.01738, -8.74725 )
|
position = Vector2( -5.01738, -8.74725 )
|
||||||
rotation = -1.47386e-06
|
|
||||||
texture = ExtResource( 1 )
|
texture = ExtResource( 1 )
|
||||||
offset = Vector2( 0, 3 )
|
offset = Vector2( 0, 3 )
|
||||||
region_enabled = true
|
region_enabled = true
|
||||||
|
@ -16,10 +16,11 @@ environment = SubResource( 1 )
|
|||||||
|
|
||||||
[node name="TextureAtlasGenerator" type="Node2D"]
|
[node name="TextureAtlasGenerator" type="Node2D"]
|
||||||
script = ExtResource( 3 )
|
script = ExtResource( 3 )
|
||||||
_sprite_size = 40
|
_sprite_size = 38
|
||||||
_sprite_num = 16
|
_sprite_num = 16
|
||||||
_show_atlas = true
|
_show_atlas = true
|
||||||
save_texture = true
|
save_texture = true
|
||||||
|
modulate_color = Color( 0.705882, 0.705882, 0.705882, 1 )
|
||||||
animations = [ "run", "idle", "casting", "rest" ]
|
animations = [ "run", "idle", "casting", "rest" ]
|
||||||
z_index_paths = [ NodePath("Viewport/Node2D/CharacterFrontModel/Hip/Torso/remote_arm_r/remote_hand_r"), NodePath("Viewport/Node2D/CharacterFrontModel/Hip/Torso/arm_l/hand_l") ]
|
z_index_paths = [ NodePath("Viewport/Node2D/CharacterFrontModel/Hip/Torso/remote_arm_r/remote_hand_r"), NodePath("Viewport/Node2D/CharacterFrontModel/Hip/Torso/arm_l/hand_l") ]
|
||||||
instant_preview_path = NodePath("InstantPreview")
|
instant_preview_path = NodePath("InstantPreview")
|
||||||
|
@ -12,6 +12,12 @@ export (bool) var generate : bool = false setget set_generate, get_generate
|
|||||||
|
|
||||||
export (String) var output_file_name : String = "res://testsave.png"
|
export (String) var output_file_name : String = "res://testsave.png"
|
||||||
|
|
||||||
|
export(bool) var outline_image : bool = true
|
||||||
|
export(Color) var outline_color : Color = Color(0, 0, 0, 1)
|
||||||
|
|
||||||
|
export(bool) var modulate_image_color : bool = true
|
||||||
|
export(Color) var modulate_color : Color = Color(1, 1, 1, 1)
|
||||||
|
|
||||||
export (Array, String) var animations : Array
|
export (Array, String) var animations : Array
|
||||||
export (Array, NodePath) var z_index_paths : Array
|
export (Array, NodePath) var z_index_paths : Array
|
||||||
|
|
||||||
@ -116,6 +122,13 @@ func _process(delta):
|
|||||||
|
|
||||||
var frame = _viewport.get_texture().get_data()
|
var frame = _viewport.get_texture().get_data()
|
||||||
|
|
||||||
|
if modulate_image_color:
|
||||||
|
apply_modulate(frame)
|
||||||
|
|
||||||
|
if outline_image:
|
||||||
|
generate_outline(frame)
|
||||||
|
|
||||||
|
|
||||||
_sprite_preview.get_texture().set_data(frame)
|
_sprite_preview.get_texture().set_data(frame)
|
||||||
|
|
||||||
if not _running:
|
if not _running:
|
||||||
@ -232,6 +245,49 @@ func setup_direction():
|
|||||||
a.z_index = -1
|
a.z_index = -1
|
||||||
|
|
||||||
|
|
||||||
|
func generate_outline(img : Image):
|
||||||
|
img.lock()
|
||||||
|
|
||||||
|
for x in range(1, img.get_size().x - 1):
|
||||||
|
for y in range(1, img.get_size().y - 1):
|
||||||
|
var c : Color = img.get_pixel(x, y)
|
||||||
|
|
||||||
|
if is_zero_approx(c.a):
|
||||||
|
var cxn : Color = img.get_pixel(x - 1, y)
|
||||||
|
var cxp : Color = img.get_pixel(x + 1, y)
|
||||||
|
var cyn : Color = img.get_pixel(x, y - 1)
|
||||||
|
var cyp : Color = img.get_pixel(x, y + 1)
|
||||||
|
|
||||||
|
if cxn.is_equal_approx(outline_color):
|
||||||
|
cxn.a = 0
|
||||||
|
|
||||||
|
if cxp.is_equal_approx(outline_color):
|
||||||
|
cxp.a = 0
|
||||||
|
|
||||||
|
if cyn.is_equal_approx(outline_color):
|
||||||
|
cyn.a = 0
|
||||||
|
|
||||||
|
if cyp.is_equal_approx(outline_color):
|
||||||
|
cyp.a = 0
|
||||||
|
|
||||||
|
if !is_zero_approx(cxn.a) || !is_zero_approx(cxp.a) || !is_zero_approx(cyn.a) || !is_zero_approx(cyp.a):
|
||||||
|
img.set_pixel(x, y, outline_color)
|
||||||
|
|
||||||
|
img.unlock()
|
||||||
|
|
||||||
|
func apply_modulate(img : Image):
|
||||||
|
img.lock()
|
||||||
|
|
||||||
|
for x in range(1, img.get_width()):
|
||||||
|
for y in range(1, img.get_height()):
|
||||||
|
var c : Color = img.get_pixel(x, y)
|
||||||
|
|
||||||
|
c *= modulate_color
|
||||||
|
|
||||||
|
img.set_pixel(x, y, c)
|
||||||
|
|
||||||
|
img.unlock()
|
||||||
|
|
||||||
func create_atlas():
|
func create_atlas():
|
||||||
_image_texture = ImageTexture.new()
|
_image_texture = ImageTexture.new()
|
||||||
_image_texture.create_from_image(_texture, 0)
|
_image_texture.create_from_image(_texture, 0)
|
||||||
|
Binary file not shown.
Before Width: | Height: | Size: 20 KiB After Width: | Height: | Size: 41 KiB |
Loading…
Reference in New Issue
Block a user