Cat in Python

Anna Stokes
Data Mining the City
2 min readSep 20, 2017

Variable Cat:

I started playing around with shapes to make a face and realized that I could line the triangles up as ears on top of an ellipse, and so, this little digital cat was born.

size (500,500)
background (0,255,255)
#this is the head
fill(0)
headwidth = 400
headheight = 300
headx = 250
heady = 250
#these are the ears
leftear1x = 100
leftear1y = 150
leftear2x = 125
leftear2y = 50
leftear3x = 200
leftear3y = 105
rightear1x = 300
rightear1y = 105
rightear2x = 375
rightear2y = 50
rightear3x = 400
rightear3y = 150
#these are the eyes
lefteyex = 190
eyey = 190
righteyex = 320
eyewidth = 50
eyeheight = 70
#these are the pupils
leftpupilx = 190
pupily = 190
rightpupilx = 320
pupildiameter = 20
#these are the whiskers
whiskerx = 250
whiskery = 260
whisker13x = 105
whisker2x = 95
whisker46x = 395
whisker5x = 385
whisker14y = 220
whisker25y = 260
whisker36y = 280
#this is the nose
nosex = 250
nosey = 260
nosediameter = 20
#this is the whole cat
fill(0)
ellipse(headx, heady, headwidth, headheight)
triangle(leftear1x, leftear1y, leftear2x, leftear2y, leftear3x, leftear3y)
triangle(rightear1x, rightear1y, rightear2x, rightear2y, rightear3x, rightear3y)
fill(255,255,0)
ellipse(lefteyex, eyey, eyewidth, eyeheight)
ellipse(righteyex, eyey, eyewidth, eyeheight)
fill(0)
ellipse(leftpupilx, pupily, pupildiameter, pupildiameter)
ellipse(rightpupilx, pupily, pupildiameter, pupildiameter)
stroke(255,255,255)
line(whiskerx, whiskery, whisker13x, whisker14y)
line(whiskerx, whiskery, whisker2x, whisker25y)
line(whiskerx, whiskery, whisker13x, whisker36y)
line(whiskerx, whiskery, whisker46x, whisker14y)
line(whiskerx, whiskery, whisker5x, whisker25y)
line(whiskerx, whiskery, whisker46x, whisker36y)
fill(255,160,122)
ellipse(nosex, nosey, nosediameter, nosediameter)

List Cat Silhouette:

Next, I created a python code that utilized lists. I listed the X & Y coordinates that make up the ear triangles as there were some repeating variables. For other features there was less repetition so a list did not make much sense. Therefor, I stuck with a silhouette this time around.

catearsX = [100, 125, 200, 300, 375, 400]
catearsy = [150, 50, 105]

size (500,500)
background (0,255,255)
#this is the head
fill(0)
headwidth = 400
headheight = 300
headx = 250
heady = 250
#this is the whole cat
fill(0)
ellipse(headx, heady, headwidth, headheight)
triangle(catearsX[0], catearsy[0], catearsX[1], catearsy[1], catearsX[2], catearsy[2])
triangle(catearsX[3], catearsy[2], catearsX[4], catearsy[1], catearsX[5], catearsy[0])

--

--