eclipse2.py

Created by schraf

Created on October 08, 2022

514 Bytes


import turtle
from math import *
from random import random
from kandinsky import fill_rect,set_pixel

COUL = [(0,0,0),(248,0,0),(248,252,0),(248,252,248)]
fill_rect(0,0,320,222,COUL[0])

tt = turtle
tt.speed(0)
tt.hideturtle()

a = pi * (1 + sqrt(5))
s, c = sin(a), cos(a)
x, y = 80, 0
n = 3000

for i in range(n):
  x, y = x * c - y * s, x * s + y * c
  tt.color(COUL[1 + (3 * i) // n])
  k = 1 - i / n
  r = 1 + k * k * random()
  tt.penup()
  tt.goto(x, y)
  tt.pendown()
  tt.goto(x * r, y * r)