From 410ebbf428c1d07a7fd064d3d67aac1c5a1fd1c4 Mon Sep 17 00:00:00 2001 From: Simon Forman Date: Thu, 11 Apr 2024 21:19:34 -0700 Subject: [PATCH] Use Poisson process to lay out stars. It actually looks better the other way? --- ui.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/ui.py b/ui.py index af13b39..9f1056e 100644 --- a/ui.py +++ b/ui.py @@ -3,6 +3,7 @@ from tkinter import * from PIL import Image from PIL.ImageTk import PhotoImage +from poisson import poisson class App: @@ -43,16 +44,19 @@ class App: -from random import randint, expovariate +from random import randint, expovariate, seed + +seed(23) width, height = 10240, 7680 root = Tk() app = App(root, bg='black', scrollregion=(0, 0, width, height)) app.frame.pack(expand=True, fill=BOTH) +k = poisson(width, height, 160) -for _ in range(1000): - x, y = randint(0, width - 1), randint(0, height - 1) +for x, y in k: + #x, y = randint(0, width - 1), randint(0, height - 1) #radius = randint(2, 10) // 2 radius = round(1 + expovariate(1)) app.canvas.create_oval(