Skip to content

Instantly share code, notes, and snippets.

@rors
Forked from gretaf007/homework03_greta
Last active September 22, 2020 00:03
Show Gist options
  • Save rors/3089ae55aa3106112aff721a1588b50d to your computer and use it in GitHub Desktop.
Save rors/3089ae55aa3106112aff721a1588b50d to your computer and use it in GitHub Desktop.
"""
Greta Villani
9/16/2020
Homework 1
"""
c = color(255,150,150)
fishTailLine = 60
bodyLength = 180
bodyHeight = 80
eyeX = 285
fish2FinPointx = 227
fish2FinPointy = 273
fish1x = 0
def setup():
size(640*2,350*2)
#RasterImage
img = loadImage("sea copy.jpg")
image(img, 0, 0)
strokeWeight(10)
stroke(155,155,255,50)
frameRate(4)
def draw():
size(640*2,350*2)
#RasterImage
img = loadImage("sea copy.jpg")
image(img, 0, 0)
strokeWeight(10)
stroke(155,155,255,50)
#TailTriangle
fill(100,200,210)
triangle(490+fish1x,95, 425+fish1x,145, 490+fish1x,195)
#EllipseFrontBody
fill(100,170,255)
ellipse(340+fish1x,145, bodyLength,bodyHeight)
#eye
fill(150,100,215)
circle(eyeX+fish1x, 135, 10)
#FinLine1
stroke(204, 102, 0)
strokeWeight(5)
line(325+fish1x,150, 350+fish1x,175)
#FinLine2
stroke(204, 102, 0)
strokeWeight(5)
line(370+fish1x,150, 350+fish1x,175)
#TailTriangle 2
fill(100,200,210)
triangle(fishTailLine,195, 145,245, fishTailLine,295 )
#EllipseFrontBody 2
fill(100,170,255)
ellipse(225,245, bodyLength,bodyHeight)
#eye 2
fill(150,100,215)
circle(eyeX, 235, 10)
#FinLine1 2
stroke(204, 102, 0)
strokeWeight(5)
line(205,250, fish2FinPointx,fish2FinPointy)
#FinLine2 2
stroke(204, 102, 0)
strokeWeight(5)
line(250,250, fish2FinPointx,fish2FinPointy)
@rors
Copy link
Author

rors commented Sep 22, 2020

Oh, one other things. I mentioned that you should comment out lines 20 and 29. That is true, but will cause another problem – perhaps that problem is why you did things this way to begin. The problem has to do with scope, and the solution is to use global. Like this:

    # put these lines in the setup() block:
    global img
    img = loadImage("some-image.jpg")

    # put these lines in the draw() block:
    global img
    image(img,0,0)

We'll talk about this more on Weds.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment