untap/field.gd

35 lines
923 B
GDScript

extends TextureRect
var _screen_size: Vector2
var _colors: Array[Color]
# Called when the node enters the scene tree for the first time.
func _ready() -> void:
_screen_size = get_viewport_rect().size
# TODO: Calculate this field's scale and position based on which no# field this is.
# TODO: Method to take list of colors, split into this format of dictionary, and apply as gradient.
var gradient_data := {
0.0: Color.MAROON,
1.0: Color.MAROON,
}
var gradient := Gradient.new()
gradient.offsets = gradient_data.keys()
gradient.colors = gradient_data.values()
var gradient_texture = GradientTexture1D.new()
gradient_texture.gradient = gradient
# gradient_texture.width = _screen_size.x
texture = gradient_texture
func set_colors(colors: Array[Color]) -> void:
_colors = colors
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta: float) -> void:
pass