Created
August 11, 2018 05:16
-
-
Save maximtrp/9d7d648598c33f2333f5cb865429e8c5 to your computer and use it in GitHub Desktop.
Random circles visualization
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
import PIL.Image as pim | |
import PIL.ImageDraw as pid | |
import palettable as pal | |
circles = 10 | |
points = 9 | |
radius = 128 | |
width = 2000 | |
height = 2000 | |
colors = pal.cartocolors.qualitative.Prism_10.colors[:] | |
fg = pim.new('RGBA', (width, height), (0, 0, 0, 255)) | |
canvas = pid.Draw(fg) | |
noise = np.random.randint(0, width, (10000, 2)) | |
for z in range(circles): | |
r = radius * 1.225 ** z#radius * z * 1.1 ** z | |
p = int(points * (1.19 ** (circles - z))) | |
t = np.linspace(0, 2 * np.pi, p) | |
x, y = r * np.cos(t) + width/2, r * np.sin(t) + height/2 | |
x_min = np.min(x) | |
y_min = np.min(y) | |
x_max = np.max(x) | |
y_max = np.max(y) | |
color = tuple(colors[z]) | |
a1 = np.random.randint(0, 359) | |
a2 = np.random.randint(a1, 360) | |
for w in range(int((z+1)**1.1 * 10)): | |
#print(a1, a2) | |
canvas.arc(xy=(width/2-r-w, height/2-r-w, width/2+r+w, height/2+r+w), start=a1, end=a2, fill=color) | |
for n in noise: | |
canvas.ellipse(tuple(n.tolist() + (n + 4).tolist()), fill=tuple(np.repeat(np.random.randint(20, 55), 3))) | |
fg.resize((2000, 2000), pim.LANCZOS) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment