Week 3

Kenneth Warner
Data Mining the City
2 min readSep 27, 2017
import csv
def setup():
size(1000, 200)

with open("quakes.csv") as f:
reader = csv.reader(f)
header = reader.next() # Skip the header row.

global magnitudes
magnitudes = []

for row in reader:
magnitude = float(row[4])
magnitudes.append(magnitude)

def draw():
background(188,188,188)
scalar=10
x = 0

for magnitude in magnitudes:

leftEdge = x - (magnitude * scalar) / 2
rightEdge = x + (magnitude * scalar) / 2
if leftEdge < mouseX and mouseX < rightEdge:
fill(0)
else:
fill(247,138,29)
rectMode(CENTER)
rect(x, height / 2, magnitude*scalar, magnitude*scalar)
x += 4
def setup():
size(400, 400)
stroke(107,107,107)
strokeWeight(6)

def draw():
#this draws the head
headRadius = 300
ellipse(200, 200, headRadius, headRadius+40)
#this is for the eyes
eyeRadius = 60
eyeYPosition = 150
leftEyeXPosition = 160
rightEyeXPosition = 260
#this is where the mouth is
mouthRadius = 100
mouthX = 200
mouthY = 270
#this draws the eyes and mouth
ellipse(leftEyeXPosition, eyeYPosition, eyeRadius, eyeRadius+30)
ellipse(rightEyeXPosition, eyeYPosition, eyeRadius, eyeRadius+10)
ellipse(mouthX, mouthY, mouthRadius+70, mouthRadius)
#this is where we define our color variables
mouthColorHighlight = color(0, 255, 0)
mouthColorUnHighlighted = color(0, 0, 0)

#this is where I draw the shapes of the face
fill(255, 0, 0)
ellipse(leftEyeXPosition, eyeYPosition, eyeRadius, eyeRadius)
fill(0, 0, 0)
ellipse(rightEyeXPosition, eyeYPosition, eyeRadius, eyeRadius)

if mouseX < 250:
fill(mouthColorHighlight)
ellipse(mouthX, mouthY, mouthRadius+70, mouthRadius)
else:
fill(mouthColorUnHighlighted)
ellipse(mouthX, mouthY, mouthRadius+70, mouthRadius)

if mousePressed:
ellipse(mouthX+30, mouthY+10, mouthRadius*2, mouthRadius)

--

--