Ce script génère des galaxies spiralées avec des étoiles colorées.
from kandinsky import * import random import math def fractal_plants(): def draw_branch(x, y, angle, length, depth): if depth == 0 or length < 1: return x_end = x + int(math.cos(angle) * length) y_end = y + int(math.sin(angle) * length) if 0 <= x_end < 320 and 0 <= y_end < 222: color = (0, random.randint(100, 255), 0) set_pixel(x_end, y_end, color) draw_branch(x_end, y_end, angle + random.uniform(0.1, 0.5), length * 0.75, depth - 1) draw_branch(x_end, y_end, angle - random.uniform(0.1, 0.5), length * 0.75, depth - 1) for _ in range(10): # Draw 10 plants x = random.randint(100, 220) y = random.randint(150, 200) angle = -math.pi / 2 length = random.randint(30, 50) depth = random.randint(3, 6) draw_branch(x, y, angle, length, depth) fractal_plants()