HOME | DD

Published: 2022-04-15 16:53:20 +0000 UTC; Views: 71; Favourites: 1; Downloads: 0
Redirect to original
Description
Kode now reads hex numbers from file. In this case a set of 'neon' RGB values. This is all still one big hack of for-grabs examples, I haven't R a single FM, haha.# Set to local path. One RGB value per line, nothing else. No error checks whatsoever are performed.
palette = '/home/nobody/palette.txt'
with open(palette, 'r') as f:
rgblist = f.read().splitlines()
rgbmax = len(rgblist) - 1
f.close()
l1 = layer('Squares')
l2 = layer('Circles')
l3 = layer('raster')
for y in range(0, int(height), 100):
for x in range(0, int(width), 100):
rgbindex = randrange(rgbmax)
r1 = rect((x, y), (x + 100, y + 100), stroke_width=0, fill='#%s' % rgblist[rgbindex])
l1.add(r1)
rgbindex = randrange(rgbmax)
c1 = circle((x + 50 + uniform(-2, 2), y + 50 + uniform(-2.5, 2.5)), 25, stroke_width=0, fill='#%s' % rgblist[rgbindex])
l2.add(c1)
r2 = rect((x, y), (x + 100, y + 100), stroke_width=0, fill='#0062afx ').to_path()
c2 = circle((x + 50, y + 50), 30).to_path()
r2.append(c2)
l3.add(r2)