Final project for the "Designing with Python: Programming for a Visual Context" course. Posters coded in Python using the py5 library.
See below for the code used for generating the posters:
Poster 1:
save_document = False
def draw():
global save_document
if save_document:
begin_record(PDF, 'poster.pdf')
def setup ():
size(2646, 3778)
background(0, 0, 200)
w = (sqrt(3) * 100)
h = 100
fill(187, 143, 171)
for i in range(30):
for j in range(0, 30, 3):
for k in range(-1, 30, 2):
for l in range(1, 30, 2):
tile1(i * w, j * h, 50, 100)
tile1(k * (w/2), h * l * 1.5, 50, 100)
fill(0, 71, 171)
for j in range(0, 30, 3):
for i in range(30):
for k in range(-1, 30, 2):
for l in range(1, 30, 2):
tile3(i * w, j * h, 50, 100)
tile3(k * (w/2), h * l * 1.5, 50, 100)
fill(138, 176, 230)
for j in range(0, 30, 3):
for i in range(30):
for k in range(-1, 30, 2):
for l in range(1, 30, 2):
tile2(i * w, j * h, 50, 100)
tile2(k * (w/2), h * l * 1.5, 50, 100)
def tile1(xc, yc, wa, wb):
pts = [(0, 0), ((sqrt(3) / 2) * wb, wa), ((sqrt(3) / 2) * wb, wa + wb),
(0, wb)
]
begin_shape()
for x, y in pts:
vertex(xc + x, yc + y) # function with ordinates of a polygon
end_shape(CLOSE)
def tile2(xc, yc, wa, wb):
pts2 = [(0, 0), ((sqrt(3) / 2) * wb, -wa), (sqrt(3) * wb, 0),
((sqrt(3) / 2) * wb, wa)
]
begin_shape()
for x, y in pts2:
vertex(xc + x, yc + y) # function with ordinates of a polygon
end_shape(CLOSE)
def tile3(xc, yc, wa, wb):
pts3 = [((sqrt(3) / 2) * wb, wa), (sqrt(3) * wb, 0),
(sqrt(3) * wb, wb), ((sqrt(3) / 2) * wb, wa + wb)
]
begin_shape()
for x, y in pts3:
vertex(xc + x, yc + y) # function with ordinates of a polygon
end_shape(CLOSE)
if save_document:
end_record()
save_document = False
def key_pressed():
global save_document
if key == 'p':
save_document = True
print('saving')
Poster 2:
save_document = False
def setup():
size(1417, 1975)
background(100)
def draw():
global save_document
if save_document:
begin_record(PDF, 'poster_b.pdf')
# Start the sequence at -1 for tile1 and alternate with tile2 up to 30
for j in range(-1, 50):
if j % 2 == -1 % 2: # For odd positions (like -1, 1, 3, 5,...), call tile1
tile1(j)
else: # For even positions (like 0, 2, 4, 6,...), call tile2
tile2(j)
if save_document:
end_record()
save_document = False
def tile1(j):
num = 3
w = width/num #1000/10
a = 0.28 #y offset
no_stroke()
for i in range(-1, num + 5):
fill(226, 118, 89)
circle(w + i * 0.9 * w - (0.1 * w) / 2 - 0.9 * w, w / 2 + j * a * w, w)
fill(0, 92, 83)
circle(w + i * 0.9 * w - (0.1 * w) / 2 - 0.9 * w, w / 2 + j * a * w, 9 / 10 * w)
fill(226, 118, 89)
circle(w + i * 0.9 * w - (0.1 * w) / 2 - 0.9 * w, w / 2 + j * a * w, 8 / 10 * w)
fill(0, 92, 83)
circle(w + i * 0.9 * w - (0.1 * w) / 2 - 0.9 * w, w / 2 + j * a * w, 7 / 10 * w)
fill(226, 118, 89)
circle(w + i * 0.9 * w - (0.1 * w) / 2 - 0.9 * w, w / 2 + j * a * w, 6 / 10 * w)
fill(0, 92, 83)
circle(w + i * 0.9 * w - (0.1 * w) / 2 - 0.9 * w, w / 2 + j * a * w, 5 / 10 * w)
fill(226, 118, 89)
circle(w + i * 0.9 * w - (0.1 * w) / 2 - 0.9 * w, w / 2 + j * a * w, 4 / 10 * w)
fill(0, 92, 83)
circle(w + i * 0.9 * w - (0.1 * w) / 2 - 0.9 * w, w / 2 + j * a * w, 3 / 10 * w)
def tile2(j):
num = 3
w = width/num #1000/10
a = 0.28 #y offset
no_stroke()
for i in range(-1, num + 5):
fill(226, 118, 89)
circle(w / 2 + i * 0.9 * w, w / 2 + j * a * w, w)
fill(0, 92, 83)
circle(w / 2 + i * 0.9 * w, w / 2 + j * a * w, 9 / 10 * w)
fill(226, 118, 89)
circle(w / 2 + i * 0.9 * w, w / 2 + j * a * w, 8 / 10 * w)
fill(0, 92, 83)
circle(w / 2 + i * 0.9 * w, w / 2 + j * a * w, 7 / 10 * w)
fill(226, 118, 89)
circle(w / 2 + i * 0.9 * w, w / 2 + j * a * w, 6 / 10 * w)
fill(0, 92, 83)
circle(w / 2 + i * 0.9 * w, w / 2 + j * a * w, 5 / 10 * w)
fill(226, 118, 89)
circle(w / 2 + i * 0.9 * w, w / 2 + j * a * w, 4 / 10 * w)
fill(0, 92, 83)
circle(w / 2 + i * 0.9 * w, w / 2 + j * a * w, 3 / 10 * w)
def key_pressed():
global save_document
if key == 's':
save_frame('poster_b.pdf')
print('saved pdf')
elif key == 'p':
save_document = True
print('saved PDF')