Doggy Community Grids

Zheyu Liu
Data Mining the City
2 min readSep 18, 2018

This is a doggy community where lives various kinds of dogs. Each green grid represents a dog’s playground and the six sprite houses are their dating places. Every time the mouse flies over the green grid, a dog will appear. If you are lucky, you will find two identical dogs, and they are probably the best partners to go to a dating house :)

def setup():
size(1220,740)
noStroke()
background(255)
global smallGrid, bigGrid, gap, dogImages, Dimg, Pimg, clickX, clickY
smallGrid = 100
bigGrid = 220
gap = 20
dogImages = []
for i in xrange(0, 36):
filename = "/Users/joree/Desktop/dog/" + str(i + 1) + ".jpg"
Dimg = loadImage(filename)
dogImages.append(Dimg)
Pimg = loadImage("/Users/joree/Desktop/parks/house.png")
def draw():
#draw the dogs
i = 0
for bundle in xrange(0,3):
for row in xrange(0,6):
for column in xrange(0,2):
x = 20+480*bundle+column*(smallGrid+gap)
y = 20+row*(smallGrid+gap)
Dimg = dogImages[i]
image(Dimg,x,y,smallGrid,smallGrid)
mouseIsOverDog = (x < mouseX and mouseX < x + smallGrid) and(y < mouseY and mouseY < y + smallGrid)
fill(146,246,97)
rect(20+480*bundle+column*(smallGrid+gap),
20+row*(smallGrid+gap), smallGrid, smallGrid)
if mouseIsOverDog:
noFill()
image(Dimg,x,y,smallGrid,smallGrid)
i = i + 1
#draw the parks
column = 0
while column < 2:
row = 0
while row < 3:
x = 3*gap+2*smallGrid+column*(bigGrid+3*gap+2*smallGrid)
y = gap+row*(bigGrid+gap)
image(Pimg,x,y,bigGrid,bigGrid)
row = row + 1
column = column + 1
clickY = mouseY()

Reference

The dogs’ pictures are from https://www.petfinder.com/dog-breeds?see-all=1

--

--