The_Dark_Side_of_Earth/bg_image.gd

11 lines
519 B
GDScript

extends TextureRect
@export var colors : Array[Color] = [Color(0.3, 1, 1) * 0.7, Color(1, 0.6, 0.6) * 0.7, Color(1, 1, 1) * 0.7]
func _process(_delta: float) -> void:
var index : int = floor((%Player.position.angle() + PI)/ TAU * colors.size())
var diff = (%Player.position.angle() + PI)/ TAU * colors.size() - index
self.modulate = linear_color_interpolation(colors[index], colors[(index + 1) % colors.size()], diff)
func linear_color_interpolation(c1 : Color, c2 : Color, t : float):
return c1 + (c2 - c1) * t