Last active
January 25, 2021 21:05
-
-
Save joemilbourn/4ab1f91772b61903eb42d6946b9ec8ba to your computer and use it in GitHub Desktop.
test
This file contains 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
from math import * | |
from random import * | |
from kandinsky import * | |
n = 200 | |
nx = 320 | |
ny = 222 | |
fill_rect(0, 0, nx, ny, (0, 0, 0)) | |
for i in range(n): | |
c = (randint(0, 255), randint(0, 255), (int(randint(0, 255)) | 0x01)) | |
set_pixel(randint(0, nx), randint(0, ny), c) | |
changed = True | |
while changed: | |
changed = False | |
for x in range(nx): | |
for y in range(ny): | |
c = get_pixel(x, y) | |
if c[2] & 0x80 == 0x80: | |
for dx in [-1, 0, 1]: | |
for dy in [-1, 0, 1]: | |
if (x+dx > 0) and (y+dy > 0) and (x+dx < nx) and (y+dy < ny): | |
if get_pixel(x+dx, y+dy) == (0, 0, 0): | |
set_pixel(x+dx, y+dy, (c[0], c[1], c[2] & ~0x80)) | |
changed = True | |
for x in range(nx): | |
for y in range(ny): | |
c = get_pixel(x, y) | |
if c != (0, 0, 0): | |
set_pixel(x, y, (c[0], c[1], int(c[2]) | 0x80)) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment