background

This commit is contained in:
Kirill
2025-11-15 08:22:49 +03:00
parent 7c5867f606
commit aecce7d1c4
6 changed files with 163 additions and 67 deletions
+13 -56
View File
@@ -1,52 +1,14 @@
extends Node2D
const STAR_COLOR_DISTRIBUTION = [
[700, '#8FA8FFFF'],
[1700, '#8FA8FFD8'],
[3400, '#8FA8FFA0'],
[6000, '#A0B5FFFF'],
[9900, '#A0B5FFD0'],
[16400, '#A0B5FF90'],
[17300, '#B0C5FFFF'],
[18600, '#B0C5FFC8'],
[20800, '#B0C5FF88'],
[26000, '#D0DBFFFF'],
[33800, '#D0DBFFC0'],
[46800, '#D0DBFF80'],
[57200, '#F8F7FFE0'],
[72900, '#F8F7FFA8'],
[99000, '#F8F7FF70'],
[114700, '#FFF4EAD0'],
[138200, '#FFF4EA98'],
[177400, '#FFF4EA60'],
[180000, '#FFD280F0'],
[183000, '#FFD280B8'],
[189000, '#FFD28078'],
[191000, '#FFA64DF8'],
[194000, '#FFA64DC0'],
[199000, '#FFA64D80'],
[225000, '#FFE4B5C0'],
[264000, '#FFE4B588'],
[309000, '#FFE4B550'],
[364000, '#FFCC99A0'],
[441000, '#FFCC9968'],
[604000, '#FFCC9940'],
[658000, '#FFB36690'],
[753000, '#FFB3665C'],
[893000, '#FFB36630'],
[914000, '#E8F4FF80'],
[946000, '#E8F4FF50'],
[1000000, '#E8F4FF28'],
]
@export_group("Visual Settings")
@export var Star_Count: int = 5000: set = set_star_count
@export var Background_Image_Size: Vector2 = Vector2(4096, 4096): set = set_Background_Image_Size
@export var Background_Image_Size: Vector2 = Vector2(4096, 4096):
set = set_Background_Image_Size
@export var background_color: Color = Color.BLACK
@export_group("Animation")
@export var auto_rotate: bool = false
@export var rotation_speed: float = 0.1
#@export_group("Animation")
#@export var auto_rotate: bool = false
#@export var rotation_speed: float = 0.1
var rotation_angle: float = 0.0
@@ -66,24 +28,19 @@ func draw_galaxy():
for ind1 in range(Star_Count):
var star_coords = Vector2(randi_range(0, Background_Image_Size.x),
randi_range(0, Background_Image_Size.y))
var star_color = get_star_color()
draw_circle(star_coords, 1, star_color)
#draw_star(star_coords)
func _process(delta):
if auto_rotate:
rotation_angle += rotation_speed * delta
queue_redraw()
if Engine.is_editor_hint():
queue_redraw()
func get_star_color() -> Color:
#var star_color = {"rgb": Colo, "alpha": 0}
var rnd_seed = randi_range(0, STAR_COLOR_DISTRIBUTION[-1][0])
for item:Array in STAR_COLOR_DISTRIBUTION:
if rnd_seed <= item[0]:
return Color.html(item[1])
return Color.BLACK
#func draw_star(star_coords: Vector2):
#var rnd_seed = randi_range(0, STAR_COLOR_DISTRIBUTION[-1][0])
#for item:Array in STAR_COLOR_DISTRIBUTION:
#if rnd_seed <= item[0]:
#var star_color = Color.html(item[1])
#draw_circle(star_coords, 1, star_color)
#region Сеттеры для автоматического обновления
func set_Background_Image_Size(value: Vector2):