Week 4: a lantern for Halloween
Published in
1 min readOct 30, 2017
This is the latern for Halloween which moves with your mouse.
#this is the main code
from lantern import *def setup():
size(500,500)
global lanterns
lanterns = []
for w in xrange(5, 150, 5):
for z in xrange(5,150,5):
lantern = Lantern(w*10, z*10,100,22,color(255,140,0))
lanterns.append(lantern)
def draw():
background(25,25,25)
for lantern in lanterns:
lantern.draw()
#this is the class lantern
class Lantern(object):
def __init__(self, x, y, faceWidth, eyeWidth, glazing):
self.x = x
self.y = y
self.faceWidth = faceWidth
self.eyeWidth = eyeWidth
self.glazing = glazingdef draw(self):
#noFill()
#ellipse(self.x ,self.y ,15+self.faceWidth,self.faceWidth)
if dist(self.x, self.y, mouseX, mouseY) < 25:
fill(self.glazing)
ellipse(self.x ,self.y ,10+self.faceWidth,self.faceWidth)
stroke(255, 255, 255)
fill(0,0,255)
ellipse(self.x - 25,self.y - 15,self.eyeWidth,self.eyeWidth)
ellipse(self.x + 25,self.y - 15,self.eyeWidth,self.eyeWidth)
ellipse(self.x ,self.y + 15 ,25,30)
fill(255)
triangle(self.x, self.y-150, self.x+20, self.y-50, self.x-20, self.y-50)