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 21, 2020

Please let me know if you were able to receive this and if it was helpful. Thanks.

@gretaf007
Copy link

@rors
I got your edits! I will look at them tonight after class. Thanks so much!!

@rors
Copy link
Author

rors commented Sep 21, 2020

👍

@gretaf007
Copy link

@rors
Oh! I forgot, I couldn't figure out how to make the jpg bigger in the background. Is this not possible because the image file is a set size?
Thanks

@rors
Copy link
Author

rors commented Sep 21, 2020

Check out the documentation for image(). You can use fourth and fifth arguments to change the display size of the image. But keep in mind that since it's a raster image, changing the size will potentially distort the image. If you want to make sure the image is not distorted, you can check the dimensions of the original image, and multiply both width and height by the same amount.

For example, if the original image was 200 pixels wide by 500 pixels tall, you could scale the image without distortion to 400,1000, but changing width and height by different amounts (for example to 400,500) would distort the image.

@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