30 lines
954 B
GDScript3
30 lines
954 B
GDScript3
|
extends Sprite2D
|
||
|
|
||
|
@export var export_path := ""
|
||
|
@export var height := 300
|
||
|
@export var l_ease_in_x := 500.0
|
||
|
@export var mid := 1000.0
|
||
|
@export var r_ease_out_x := 500.0
|
||
|
|
||
|
|
||
|
func _ready() -> void:
|
||
|
if export_path:
|
||
|
var width := (l_ease_in_x + mid + r_ease_out_x) as int
|
||
|
var image = Image.create_empty(width, height, false, Image.FORMAT_RGBA8)
|
||
|
# convert to transparent BG point light image
|
||
|
for y in range(height):
|
||
|
for x in range(width):
|
||
|
var color = Color(1.0, 1.0, 1.0, 1.0)
|
||
|
if x < l_ease_in_x:
|
||
|
# color.a = smoothstep(0.0, 1.0, x / l_ease_in_x)
|
||
|
color.a = x / l_ease_in_x
|
||
|
elif x > l_ease_in_x + mid:
|
||
|
# color.a = smoothstep(1.0, 0.0, (x - l_ease_in_x - mid) / r_ease_out_x)
|
||
|
color.a = 1.0 - (x - l_ease_in_x - mid) / r_ease_out_x
|
||
|
image.set_pixel(x, y, color)
|
||
|
image.save_png(export_path)
|
||
|
texture = ImageTexture.create_from_image(image)
|
||
|
print("Exported to: " + export_path)
|
||
|
else:
|
||
|
print("No export path found")
|