Homework 7: Processing Intro

Update: example solutions posted.

Due: Thursday Nov 15, 11:59PM.

To submit: Send an email to me at jal2016@email.vccs.edu with subject CSC 110 HW7 with your program(s) attached in a zip file.

Note that every Processing program consists of a directory with one or more .pde files inside. Simple programs will have just a single file, that by default will have the same base name as the directory. Your zip file should preserve the directory structure.

For any problems that require just a single file (like both programs for this homework), your source files and directories should be named with the form NAME_HW#_PROBLEM#.pde. For example, I would save problem #2 for this assignment with the name lepak_hw7_2.pde. Include a comment at the top of all programs that you submit, of the following form (shown for my same example):

// Joel Lepak
// CSC 110 HW7 #2
  1. Create a program that draws a self-portrait. It doesn't have to be a moving work of art, but it should be more complicated than a circle with two dots for eyes (use at least 10 or so statements).

    size(300, 300);
    // Head
    fill(0xFF, 0xE2, 0xA7);
    ellipse(width/2, height/2, 150, 200);
    // Eyes
    ellipse(width/2 + 25, height/2, 30, 30);
    ellipse(width/2 - 25, height/2, 30, 30);
    ellipse(width/2 + 25, height/2, 15, 15);
    ellipse(width/2 - 25, height/2, 15, 15);
    // Glasses
    arc(width/2 + 25, height/2 - 15, 50, 70, 0, PI);
    arc(width/2 - 25, height/2 - 15, 50, 70, 0, PI);
    line(width/2 - 50, height/2 - 15,
    width/2 + 50, height/2 - 15);
    // Mouth
    arc(width/2, height/2 + 30, 100, 50, 0, PI);
    line(width/2 - 50, height/2 + 30,
    width/2 + 50, height/2 + 30);
    // Hair
    fill(0xF9, 0xFF, 0x67);
    for (float i = PI/3; i < 2*PI/3; i = i + 0.01)
      vertex(width/2 + cos(i) * 75 + random(-50, 50),
        height/2 - sin(i) * 100 + random(-50, 50));
  2. Create another program that draws a picture using several different colors. Use the fill and stroke functions to set colors for shapes and lines. Your program should use different versions of each function (versions that accept different numbers of arguments). Pay attention to the difference between the versions. Experiment at least once with overlapping shapes that use a fill color with a non-default alpha component (which you can specify using the 4-argument version of fill).

    See also the reference for the color datatype.

  3. I might post some submissions as examples. Please tell me:

    • Do you give permission to post your submissions to this website?
    • If yes, what name would you like to be credited with? (I.e. do you want to be anonymous or not?)

    I'll assume your preference applies to future assignments unless you change your preference later.