Ce script génère des galaxies spiralées avec des étoiles colorées.
from kandinsky import * import random import math def galaxies(): def draw_galaxy(cx, cy, num_arms, arm_length, arm_spread, num_stars): for _ in range(num_stars): angle = random.uniform(0, 2 * math.pi) radius = random.uniform(0, arm_length) arm_angle = angle + radius / arm_length * arm_spread x = cx + int(radius * math.cos(arm_angle)) y = cy + int(radius * math.sin(arm_angle)) if 0 <= x < 320 and 0 <= y < 222: color = (255, random.randint(0, 255), random.randint(0, 255)) set_pixel(x, y, color) for _ in range(5): # Draw 5 galaxies cx = random.randint(0, 319) cy = random.randint(0, 221) num_arms = random.randint(3, 6) arm_length = random.randint(50, 100) arm_spread = random.uniform(0.5, 1.5) num_stars = random.randint(200, 500) draw_galaxy(cx, cy, num_arms, arm_length, arm_spread, num_stars) galaxies()