Class in python

Based on what I have drawn with slippymapper for crime incidents, I add a class called “title” to write a title for this project in the top-left corner.

Code:

import spatialpixel.mapping.slippymapper as slippymapper
import csv
from title import *
def setup():
size(1000,800,P2D)
global nyc,marker

nyc = slippymapper.SlippyMapper(40.775070, -73.970252, 12, "carto-dark",width,height)

with open('data.csv') as f:
reader = csv.reader(f)
header = reader.next()

for row in reader:
latitude = float(row[6])
longitude = float(row[7])
nyc.addMarker(latitude,longitude)

marker = title(width/4,100,"Crime Visualization")

nyc.render()

def draw():
global marker
background(255)
nyc.draw()
marker.title()

Code for class “title”

class title(object):
def __init__(self, x, y, content):
self.x = x
self.y = y
self.content = content
textAlign(CENTER,CENTER)


def title(self):
noStroke()
fill(255,0,0)
textSize(20)
text(self.content,self.x,self.y)
One clap, two clap, three clap, forty?

By clapping more or less, you can signal to us which stories really stand out.