- Daily 8 -

I spent more time than would be reasonable to implement squares that flip. First I tried to avoid saving their states, but got fed up and just did things with a class. Still grumpy that I couldn't find a nicer way.

Next time I'll see if trig motion makes this less monotonous

messy source code 

i'm sorry, this is really bad atm!

size(548, 548)
speed(30)
rectmode(CENTER)
background("")

rsz = 30
cols = 16
rows = 16

class LilSquare:
def __init__(self, step=3, sz=rsz, offset=0.5, gap=2):
self.step = step
self.size = sz
self.offset = offset
self.flipped = False
self.gap = gap
self.frontcolor = "#283618"
self.backcolor = ""
self.stepamount = self.offset

def next(self):
if self.step >= self.size:
self.stepamount = -self.offset
elif self.step <= 1:
self.stepamount = self.offset
self.flipped = not self.flipped
self.step += self.stepamount

def draw(self, x, y):
col = self.backcolor if self.flipped else self.frontcolor
rect(x, y, self.step-self.gap/2, self.size-self.gap/2, fill=col)

lilsquares = [[LilSquare(step=x%3+y%2, offset=(y+1)%4+0.2) for y in range(rows)] for x in range(cols)]

def draw():
global lilsquares
translate(50, 50)

firstlsq = lilsquares[0][6]

for x,y in grid(cols, rows, rsz, rsz):
tx, ty = (int(x/rsz), int(y/rsz))
lsq = lilsquares[tx][ty]
lsq.next()
lsq.draw(x,y)

Show thread

messy source code 

@raphael Because I just can't get hashtags right, yesterday I just mistyped and used plural x( not really sure how to make things right at the moment

Follow

messy source code 

@rlafuente Ok! At least I can see your other posts here post.lurk.org/tags/ShoebotSket

· · Web · 0 · 0 · 1
Sign in to participate in the conversation
post.lurk.org

Welcome to post.lurk.org, an instance for discussions around cultural freedom, experimental, new media art, net and computational culture, and things like that.