1
0
Fork 0
mirror of https://github.com/Orama-Interactive/Pixelorama.git synced 2025-01-18 17:19:50 +00:00

Merge onion skinning past and future into one script

This commit is contained in:
Manolis Papadeas 2021-11-26 03:38:00 +02:00
parent 159a821dd2
commit 540a61ae4d
8 changed files with 58 additions and 59 deletions

View file

@ -96,8 +96,6 @@ var onion_skinning := false
var onion_skinning_past_rate := 1.0
var onion_skinning_future_rate := 1.0
var onion_skinning_blue_red := false
var past_above_canvas := true
var future_above_canvas := true
# Palettes
var palettes := {}

View file

@ -19,6 +19,10 @@ onready var previews = $Previews
# Called when the node enters the scene tree for the first time.
func _ready() -> void:
$OnionPast.type = $OnionPast.PAST
$OnionPast.blue_red_color = Color.blue
$OnionFuture.type = $OnionFuture.FUTURE
$OnionFuture.blue_red_color = Color.red
var frame: Frame = new_empty_frame(true)
Global.current_project.frames.append(frame)
yield(get_tree(), "idle_frame")

View file

@ -1,4 +1,4 @@
[gd_scene load_steps=16 format=2]
[gd_scene load_steps=15 format=2]
[ext_resource path="res://src/UI/Canvas/Canvas.gd" type="Script" id=1]
[ext_resource path="res://src/UI/Canvas/Grid.gd" type="Script" id=2]
@ -10,8 +10,7 @@
[ext_resource path="res://src/UI/Canvas/Selection.gd" type="Script" id=8]
[ext_resource path="res://src/Shaders/MarchingAntsOutline.shader" type="Shader" id=9]
[ext_resource path="res://src/Shaders/AutoInvertColors.shader" type="Shader" id=10]
[ext_resource path="res://src/UI/Canvas/OnionFuture.gd" type="Script" id=11]
[ext_resource path="res://src/UI/Canvas/OnionPast.gd" type="Script" id=12]
[ext_resource path="res://src/UI/Canvas/OnionSkinning.gd" type="Script" id=12]
[sub_resource type="CanvasItemMaterial" id=1]
blend_mode = 4
@ -71,4 +70,4 @@ script = ExtResource( 7 )
script = ExtResource( 12 )
[node name="OnionFuture" type="Node2D" parent="."]
script = ExtResource( 11 )
script = ExtResource( 12 )

View file

@ -1,22 +0,0 @@
extends Node2D
func _draw() -> void:
if Global.onion_skinning:
if Global.onion_skinning_future_rate > 0:
var color : Color
if Global.onion_skinning_blue_red:
color = Color.red
else:
color = Color.white
for i in range(1, Global.onion_skinning_future_rate + 1):
if Global.current_project.current_frame < Global.current_project.frames.size() - i:
var layer_i := 0
for layer in Global.current_project.frames[Global.current_project.current_frame + i].cels:
if Global.current_project.layers[layer_i].visible:
#ignore layer if it has "onion_ignore" in its name (case in-sensitive).
if not "ignore_onion" in Global.current_project.layers[layer_i].name.to_lower():
color.a = 0.6 / i
draw_texture(layer.image_texture, Vector2.ZERO, color)
update()
layer_i += 1

View file

@ -1,22 +0,0 @@
extends Node2D
func _draw() -> void:
if Global.onion_skinning:
if Global.onion_skinning_past_rate > 0:
var color: Color
if Global.onion_skinning_blue_red:
color = Color.blue
else:
color = Color.white
for i in range(1, Global.onion_skinning_past_rate + 1):
if Global.current_project.current_frame >= i:
var layer_i := 0
for layer in Global.current_project.frames[Global.current_project.current_frame - i].cels:
if Global.current_project.layers[layer_i].visible:
#ignore layer if it has "onion_ignore" in its name (case in-sensitive).
if not "ignore_onion" in Global.current_project.layers[layer_i].name.to_lower():
color.a = 0.6 / i
draw_texture(layer.image_texture, Vector2.ZERO, color)
update()
layer_i += 1

View file

@ -0,0 +1,38 @@
extends Node2D
enum { PAST, FUTURE }
var type := PAST
var blue_red_color := Color.blue
var rate := Global.onion_skinning_past_rate
func _draw() -> void:
if !Global.onion_skinning:
return
rate = Global.onion_skinning_past_rate if type == PAST else Global.onion_skinning_future_rate
if rate > 0:
var color: Color
if Global.onion_skinning_blue_red:
color = blue_red_color
else:
color = Color.white
for i in range(1, rate + 1):
var change = Global.current_project.current_frame
if type == PAST:
change -= i
else:
change += i
if change == clamp(change, 0, Global.current_project.frames.size() - 1):
var layer_i := 0
for layer in Global.current_project.frames[change].cels:
if Global.current_project.layers[layer_i].visible:
# Ignore layer if it has "onion_ignore" in its name (case in-sensitive)
if not (
"ignore_onion"
in Global.current_project.layers[layer_i].name.to_lower()
):
color.a = 0.6 / i
draw_texture(layer.image_texture, Vector2.ZERO, color)
layer_i += 1

View file

@ -9,6 +9,8 @@ var is_mouse_hover := false
var cel_size := 36 setget cel_size_changed
var min_cel_size := 36
var max_cel_size := 144
var past_above_canvas := true
var future_above_canvas := true
var timeline_scroll: ScrollContainer
var tag_scroll_container: ScrollContainer
@ -528,13 +530,13 @@ func _on_BlueRedMode_toggled(button_pressed: bool) -> void:
func _on_PastPlacement_item_selected(index):
Global.past_above_canvas = (index == 0)
Global.canvas.get_node("OnionPast").set("show_behind_parent", !Global.past_above_canvas)
past_above_canvas = (index == 0)
Global.canvas.get_node("OnionPast").set("show_behind_parent", !past_above_canvas)
func _on_FuturePlacement_item_selected(index):
Global.future_above_canvas = (index == 0)
Global.canvas.get_node("OnionFuture").set("show_behind_parent", !Global.future_above_canvas)
future_above_canvas = (index == 0)
Global.canvas.get_node("OnionFuture").set("show_behind_parent", !future_above_canvas)
# Layer buttons

View file

@ -950,7 +950,7 @@ margin_bottom = 140.0
alignment = 2
[node name="Label" type="Label" parent="OnionSkinningSettings/OnionSkinningButtons/PastPlace"]
margin_left = 30.0
margin_left = 34.0
margin_top = 3.0
margin_right = 171.0
margin_bottom = 17.0
@ -962,6 +962,7 @@ valign = 1
margin_left = 175.0
margin_right = 292.0
margin_bottom = 20.0
mouse_default_cursor_shape = 2
text = "Above Canvas"
items = [ "Above Canvas", null, false, 0, null, "Below Canvas", null, false, 1, null ]
selected = 0
@ -976,7 +977,7 @@ margin_bottom = 164.0
alignment = 2
[node name="Label" type="Label" parent="OnionSkinningSettings/OnionSkinningButtons/FuturePlace"]
margin_left = 16.0
margin_left = 20.0
margin_top = 3.0
margin_right = 171.0
margin_bottom = 17.0
@ -988,6 +989,7 @@ valign = 1
margin_left = 175.0
margin_right = 292.0
margin_bottom = 20.0
mouse_default_cursor_shape = 2
text = "Above Canvas"
items = [ "Above Canvas", null, false, 0, null, "Below Canvas", null, false, 1, null ]
selected = 0
@ -998,7 +1000,7 @@ margin_right = 292.0
margin_bottom = 233.0
custom_colors/font_color = Color( 0.333333, 0.901961, 0.462745, 1 )
text = "Note:
If you want a layer to ignore Onion-skinning simply add \"ignore_onion\" in its name
If you want a layer to ignore onion skinning simply add \"ignore_onion\" in its name
(it is case-insensitive)"
align = 1
valign = 1