Gerador de vídeos narrativos (Godot + FFmpeg), painel Next.js, serviço de voz, Clipador de lives e Publicador para YouTube, TikTok e Instagram. Inclui a leitura das visualizações dos posts para o Dashboard e o botão "Publicar no <rede>" nos cartões das publicações. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
145 lines
5.1 KiB
GDScript
145 lines
5.1 KiB
GDScript
extends CanvasLayer
|
|
## Textos finais: chamada + duas opções visuais (sem votação real).
|
|
##
|
|
## `evaluate` é pura (depende só de t e da configuração); `apply` só copia o
|
|
## resultado para os nós. As medidas são proporcionais à altura do viewport,
|
|
## então a composição é a mesma em 540x960 e 1080x1920.
|
|
##
|
|
## Composição vertical (fração da altura):
|
|
## título até 0.665 (cresce para cima se quebrar linha) | opção A 0.675 |
|
|
## opção B 0.757 | 0.825..1.0 livre para a interface da plataforma.
|
|
## Margens laterais de 9% da largura.
|
|
|
|
const STAGGER_SECONDS := 0.22
|
|
const SLIDE_FRACTION := 0.025
|
|
|
|
const TITLE_BOTTOM_Y := 0.665
|
|
const TITLE_BOX_HEIGHT := 0.15
|
|
const CHOICE_A_Y := 0.675
|
|
const CHOICE_B_Y := 0.757
|
|
const CHOICE_HEIGHT := 0.068
|
|
const SIDE_MARGIN := 0.09
|
|
|
|
const ACCENT_A := Color("#F2B134")
|
|
const ACCENT_B := Color("#3FC1C9")
|
|
|
|
var _shade: TextureRect
|
|
var _title: Label
|
|
var _choice_a: PanelContainer
|
|
var _choice_b: PanelContainer
|
|
var _debug: Label
|
|
var _size := Vector2.ZERO
|
|
|
|
|
|
static func evaluate(cfg: Dictionary, t: float) -> Dictionary:
|
|
var o: Dictionary = cfg.overlay
|
|
var fade: float = maxf(o.fade_seconds, 0.001)
|
|
return {
|
|
"visible": t >= o.start,
|
|
"shade": _ease(t, o.start - 0.2, fade + 0.2),
|
|
"title": _ease(t, o.start, fade),
|
|
"choice_a": _ease(t, o.start + STAGGER_SECONDS, fade),
|
|
"choice_b": _ease(t, o.start + STAGGER_SECONDS * 2.0, fade),
|
|
}
|
|
|
|
|
|
static func _ease(t: float, start: float, length: float) -> float:
|
|
var p := clampf((t - start) / length, 0.0, 1.0)
|
|
return 1.0 - pow(1.0 - p, 3.0)
|
|
|
|
|
|
func setup(cfg: Dictionary, viewport_size: Vector2, show_debug: bool) -> void:
|
|
layer = 10
|
|
_size = viewport_size
|
|
var h := viewport_size.y
|
|
var w := viewport_size.x
|
|
|
|
# Escurecimento suave na metade de baixo para o texto ter contraste
|
|
# sobre qualquer cenário.
|
|
var gradient := Gradient.new()
|
|
gradient.set_color(0, Color(0, 0, 0, 0))
|
|
gradient.set_color(1, Color(0, 0, 0, 0.72))
|
|
var tex := GradientTexture2D.new()
|
|
tex.gradient = gradient
|
|
tex.fill_from = Vector2(0, 0)
|
|
tex.fill_to = Vector2(0, 1)
|
|
tex.width = 4
|
|
tex.height = 256
|
|
_shade = TextureRect.new()
|
|
_shade.texture = tex
|
|
_shade.stretch_mode = TextureRect.STRETCH_SCALE
|
|
_shade.position = Vector2(0, h * 0.45)
|
|
_shade.size = Vector2(w, h * 0.55)
|
|
add_child(_shade)
|
|
|
|
_title = Label.new()
|
|
_title.text = cfg.overlay.title
|
|
_title.horizontal_alignment = HORIZONTAL_ALIGNMENT_CENTER
|
|
_title.vertical_alignment = VERTICAL_ALIGNMENT_BOTTOM
|
|
_title.autowrap_mode = TextServer.AUTOWRAP_WORD_SMART
|
|
_title.add_theme_font_size_override("font_size", int(h * 0.044))
|
|
_title.add_theme_color_override("font_color", Color.WHITE)
|
|
_title.add_theme_color_override("font_outline_color", Color(0, 0, 0, 0.9))
|
|
_title.add_theme_constant_override("outline_size", maxi(2, int(h * 0.007)))
|
|
_title.add_theme_color_override("font_shadow_color", Color(0, 0, 0, 0.55))
|
|
_title.add_theme_constant_override("shadow_offset_y", maxi(1, int(h * 0.003)))
|
|
_title.size = Vector2(w * (1.0 - SIDE_MARGIN * 2.0), h * TITLE_BOX_HEIGHT)
|
|
add_child(_title)
|
|
|
|
_choice_a = _make_choice(cfg.overlay.choice_a, ACCENT_A, viewport_size)
|
|
_choice_b = _make_choice(cfg.overlay.choice_b, ACCENT_B, viewport_size)
|
|
|
|
_debug = Label.new()
|
|
_debug.visible = show_debug
|
|
_debug.position = Vector2(w * 0.03, h * 0.02)
|
|
_debug.add_theme_font_size_override("font_size", int(h * 0.022))
|
|
_debug.add_theme_color_override("font_color", Color.YELLOW)
|
|
_debug.add_theme_color_override("font_outline_color", Color.BLACK)
|
|
_debug.add_theme_constant_override("outline_size", 4)
|
|
add_child(_debug)
|
|
|
|
|
|
func _make_choice(text: String, accent: Color, viewport_size: Vector2) -> PanelContainer:
|
|
var h := viewport_size.y
|
|
var w := viewport_size.x
|
|
var style := StyleBoxFlat.new()
|
|
style.bg_color = Color(0.06, 0.07, 0.09, 0.82)
|
|
style.border_color = accent
|
|
style.set_border_width_all(maxi(2, int(h * 0.0035)))
|
|
style.set_corner_radius_all(int(h * 0.016))
|
|
style.content_margin_left = w * 0.05
|
|
style.content_margin_right = w * 0.05
|
|
|
|
var panel := PanelContainer.new()
|
|
panel.add_theme_stylebox_override("panel", style)
|
|
panel.size = Vector2(w * (1.0 - SIDE_MARGIN * 2.0), h * CHOICE_HEIGHT)
|
|
|
|
var label := Label.new()
|
|
label.text = text
|
|
label.vertical_alignment = VERTICAL_ALIGNMENT_CENTER
|
|
label.clip_text = true
|
|
label.text_overrun_behavior = TextServer.OVERRUN_TRIM_ELLIPSIS
|
|
label.add_theme_font_size_override("font_size", int(h * 0.032))
|
|
label.add_theme_color_override("font_color", Color.WHITE)
|
|
panel.add_child(label)
|
|
add_child(panel)
|
|
return panel
|
|
|
|
|
|
func apply(state: Dictionary, debug_text: String = "") -> void:
|
|
var w := _size.x
|
|
var h := _size.y
|
|
var x := w * SIDE_MARGIN
|
|
_shade.modulate.a = state.shade if state.visible else 0.0
|
|
_place(_title, x, TITLE_BOTTOM_Y - TITLE_BOX_HEIGHT, state.title, state.visible)
|
|
_place(_choice_a, x, CHOICE_A_Y, state.choice_a, state.visible)
|
|
_place(_choice_b, x, CHOICE_B_Y, state.choice_b, state.visible)
|
|
if _debug.visible:
|
|
_debug.text = debug_text
|
|
|
|
|
|
func _place(node: Control, x: float, y_fraction: float, amount: float, overlay_visible: bool) -> void:
|
|
node.visible = overlay_visible and amount > 0.0
|
|
node.modulate.a = amount
|
|
node.position = Vector2(x, _size.y * (y_fraction + SLIDE_FRACTION * (1.0 - amount)))
|