My Button gets a new color by it's parent ... it seems to 'flash' black now and then and I think when RGB channels do not overlap?
Code draws a rect in given color. Can I somehow prevent this flashing? Guess not using the module but change the color change steps myself?
extends Button
@export var color:Color = Color.WHITE:
set(v):
prints("color.set", color, '->', v)
color = v
flash()
queue_redraw()
func _ready():
custom_minimum_size = Vector2(400,400)
func flash():
if is_node_ready():
var tween = get_tree().create_tween()
tween.tween_property(self, "modulate", color, 1)
func _draw():
draw_rect(Rect2(Vector2.ZERO, size), color, true)
var ticks:int = 0
var colors: Array[Color] = [Color(1, 0, 0),Color(0, 1, 0),Color(1, 1, 0),Color(0, 0, 1),Color(1, 0, 1),Color(0, 1, 1),Color(1, 1, 1),]
var color_index = 0
var interval = 180
func _process(_delta):
ticks+= 1
if ticks % interval == 0:
color = colors[color_index]
color_index += 1
color_index %= colors.size()
if ticks % 10 == 0:
printt(color)