ChocolateBird/widgets/ColorMenu.gd

39 lines
999 B
GDScript

extends Panel
var r := 0
var g := 0
var b := 16
var border_image: Image = preload('res://theme/border.png')
var border_texture := preload('res://theme/border_imagetexture.tres')
var border_stylebox := preload('res://theme/border_stylebox.tres')
const r1 := Rect2(4, 3, 2, 4)
const r2 := Rect2(3, 4, 4, 2)
func update_menu_color() -> void:
var c := Color(r/31.0, g/31.0, b/31.0)
# print(c)
$label_nums.text = '\n%d\n%d\n%d' % [r, g, b]
border_image.fill_rect(r1, c)
border_image.fill_rect(r2, c)
border_texture.set_data(border_image)
# border_stylebox.texture = border_texture
# update()
func _ready() -> void:
border_texture.create_from_image(border_image, 0)
$slider_r.value = r
$slider_g.value = g
$slider_b.value = b
func _on_slider_r_value_changed(value: float) -> void:
r = value
update_menu_color()
func _on_slider_g_value_changed(value: float) -> void:
g = value
update_menu_color()
func _on_slider_b_value_changed(value: float) -> void:
b = value
update_menu_color()