CSC 240: Computer Graphics

Homework 1: Snowflake

Due: Thursday, Sept. 17, 11:59pm on Moodle

  1. Download (and, if you haven't already). In this file, there is a class called Point and a class called Line. Complete the
  2. method for Point.

  3. Complete the
    method for Point, using the setPixel method from Lab 1.
  4. Complete the
    method for Line.
  5. Complete the
    method for Line, using the algorithm discussed in class on Monday.
  6. In the commandline, test out your code. First run:
    If everything works correctly, this should tell you what arguments the program takes. Then run:
    python hw1_your_name 400 400 
    You should get a black square. Now, in the make_image method, uncomment each line (there should be six of them) one at a time to test your line algorithm. The last line might not look very good, why is that?
  7. Finally, comment out the six existing lines, and use your line algorithm to create a simple snowflake similar to the one below (doesn't have to look exactly the same, just similar in spirit).

    Sara Sheehan
  8. Make sure your PPM is saved, and submit both your PPM and on Moodle.
BONUS: Make a more interesting snowflake! Different pattern, different color, different background color, different size. Going further: automate your snowflake drawing in a separate method, maybe something like
 def snowflake(x,y): 
that draws a snowflake centered at a specific position, (x,y). Use this method to draw multiple snowflakes. What other arguments could you add to the snowflake method?

Note: you can receive full credit for this assignment without doing the bonus, it is completely optional.