9 Squares
Published in
1 min readSep 19, 2018
Homework 02–09/19/2018
- no fill in odd squares to see the stroke drawn
- using different line weights and a white fill for even squares
- an overlay of a square within a square for the corners
- lines are drawn by clicking points, with the start point at the center of the canvas and the end point at the location clicked or (mouse pressed)
def setup():
size(720, 720)
background(255)def draw():
x = 100
y = 100
squareSize = 160
spacing = 20
for row in xrange(0, 3):
for column in xrange(0, 3):
if column == 1 and row == 1:
noFill()
strokeWeight(5)
elif column == 1 or row == 1:
fill(255)
strokeWeight(2)
else:
fill(0)
rect(x+column*(squareSize+spacing)+squareSize*.25,
y+row*(squareSize+spacing)+squareSize*.25,
squareSize/2, squareSize/2)
noFill()
rect(x+column*(squareSize+spacing),
y+row*(squareSize+spacing),
squareSize,
squareSize
)
i = 1
while i < 9:
if mousePressed == True:
line(x+column*(squareSize+spacing)+squareSize*.5,
y+row*(squareSize+spacing)+squareSize*.5,
pmouseX, pmouseY)
i += 1
stroke(0)
strokeWeight(1)