HOME | DD

Published: 2022-04-16 03:19:56 +0000 UTC; Views: 200; Favourites: 1; Downloads: 3
Redirect to original
Description
Another product of my Simple Inkscape Kod. Added some flexibility to it.inkscape.org/~pakin/%E2%98%85s…
github.com/spakin/SimpInkScr
-----------------------------------------------------------------------------------------------------------------
# Flexible code for colorful raster images with randomized colors
# Updates
# 16 Apr 2022. Generalized code; wobbly eyes dropped; replaced radiuses with diameters.
# User section
# Background and raster cells dimensions, Cell height and width values don't necessarily have to
# match, but the circles won't become ovals (yet). Factors of page dimensions for optimal results.
xcellsize = 100
ycellsize = xcellsize
cellstrokewidth = 0 # for background; meaningless with raster
# Eyes
eyesize = 40 # eye size: diameter, not radius (!)
eyestrokewidth = 0 # stroke width for eyes (with a raster: the inner circles)
# Raster
raster = 'yes' # a 'raster' is an opaque layer with 'eye sockets'
holesize = 60
rststrokewidth = 0 # raster stroke width
rasterfill = 'ffffff' # raster color
# Palette
palette = 'no' # load palette? requires a palette file
palettefile = '/home/nobody/palette.txt' # one RGB value per line, nothing else; no error checks are performed
# Code section
if palette == 'yes':
with open(palettefile, 'r') as pf:
rgblist = pf.read().splitlines()
rgbmax = len(rgblist) - 1
pf.close()
eyeradius = eyesize / 2
rstradius = holesize / 2
xoffset = xcellsize / 2
yoffset = ycellsize / 2
l1 = layer('Squares')
l2 = layer('Circles')
lif raster == 'yes': l3 = layer('raster')
for y in range(0, int(height), ycellsize):
for x in range(0, int(width), xcellsize):
# background layer
if palette == 'yes':
rgbindex = randrange(rgbmax)
r1 = rect((x, y), (x + xcellsize, y + ycellsize), stroke_width=cellstrokewidth, fill='#%s' % rgblist[rgbindex])
rgbindex = randrange(rgbmax)
else:
r1 = rect((x, y), (x + xcellsize, y + ycellsize), stroke_width=cellstrokewidth, fill='#%02x%02x%02x' % (randrange(256), randrange(256), randrange(256)))
l1.add(r1)
# eyes layer
if palette == 'yes':
c1 = circle((x + xoffset, y + yoffset), eyeradius, stroke_width=eyestrokewidth, fill='#%s' % rgblist[rgbindex])
else:
c1 = circle((x + xoffset, y + yoffset), eyeradius, stroke_width=eyestrokewidth, fill='#%02x%02x%02x' % (randrange(256), randrange(256), randrange(256)))
l2.add(c1)
# raster layer
if raster == 'yes':
# creates cool output: r2 = rect((x, y), (x + xoffset, y + yoffset), stroke_width=rststrokewidth, fill='#%s' % rasterfill).to_path()
r2 = rect((x, y), (x + xcellsize, y + ycellsize), stroke_width=rststrokewidth, fill='#%s' % rasterfill).to_path()
c2 = circle((x + xoffset, y + yoffset), rstradius).to_path()
r2.append(c2)
l3.add(r2)
-----------------------------------------------------------------------------------------------------------------
Palette: the entire set from simplicable.com/new/neon-color…
04d9ff Neon Blue
ff9933 Neon Carrot
fe4164 Neon Fuchsia
39ff14 Neon Green
fe019a Neon Pink
bc13fe Neon Purple
ff073a Neon Red
cfff04 Neon Yellow
ff0055 Pinkish Red Neon
0ff0fc Electric Cyan
fc74fd Electric Flamingo
21fc0d Electric Green
6600ff Electric Indigo
ccff00 Electric Lime
ff3503 Electric Orange
ff0490 Electric Pink
bf00ff Electric Purple
e60000 Electric Red
55ffff Electric Sheep
8f00f1 Electric Violet
fffc00 Electric Yellow
08ff08 Fluorescent Green
ffcf00 Fluorescent Orange
fe1493 Fluorescent Pink
ff5555 Fluorescent Red
fc8427 Fluorescent Red Orange
00fdff Fluorescent Turquoise
ccff02 Fluorescent Yellow
ff11ff Light Neon Pink
dfff11 Bright Chartreuse
66ff00 Bright Green
ff08e8 Bright Magenta
fe01b1 Bright Pink
be03fd Bright Purple
ff000d Bright Red
ffcf09 Bright Saffron
fc0e34 Bright Scarlet
01f9c6 Bright Teal
ff003f Electric Crimson