Objectives

Using these Lab Exercises

Please keep the following things in mind as you do the lab exercises in this course:

Operating Systems

To design and implement algorithms on a computer, you must first know how to control the basic operations of the computer. This is one the fundamental purposes of the operating system. Study the tutorial appropriate for the operating system that you will be using in these labs. It is important for craftspeople to know their tools well, so we suggest that you at least review the material even if you’ve used the system in the past.

Exercise 1.1

Do the following things on your development system:

  1. Create a sub-directory for this course (e.g., named something like cs108);
  2. Create a text file using Processing that contains your full name, what you would like to be called, and a random fact about yourself. Save this file in your course directory as aboutMe. (Note: Processing will create a directory called aboutMe that contains the file aboutMe.pde.)

You will submit this aboutMe sub-directory at the end of this lab session.

The Processing Environment

Programs are developed using a development environment such as Eclipse, Visual Studio, or Netbeans. You develop Processing programs, called sketches, using the Processing development environment.

You write program instructions in the program editor pane, press the run button, and Processing displays a new window showing your visual output. Text output, if there is any, is shown below the text output pane. As one would expect, this empty program produces an empty visual output window and no text output.

Do this...
Configure Processing to store and look for its files in the directory you created for this course. You can do this by choosing "File"-"Preferences" and changing the default directory.

Processing.org provides a reference for the Processing IDE.

Processing can generate graphical animations as shown in this example program.

void setup() {
  size(300, 300);
}

void draw() {
  fill(random(255), random(255), random(255), random(255));
  ellipse(random(300), random(300), random(150), random(150));
}

Note the following features of the this program:

One good way to learn programming is to experiment (or shall we say play) with existing programs.

Exercise 1.2

Start by copying the code given above into the Processing IDE, saving it in a sketch called Raindrops in a directory called lab01, and running it. When you’ve got that done, make modifications to the program to achieve the following goals:

  1. Make the output panel larger. When you do this successfully, you’ll see that Processing still draws the ellipses in the upper left corner of the panel, modify the program so that it draws them all over the larger output panel as it did before.
  2. Display rectangles rather than ellipses (hint, see the rect() method).
  3. Change the size of your figures in some way. You can make them larger or smaller (or wider or shorter).
  4. Modify the colors of your figures in a pleasing manner. You can make them all shades of red or purple, or reduce their level of transparency.

You can find a description of all of Processing’s methods and how to use them in the Processing reference documentation, see: Processing API.

Save a screen capture of your visual output window in the Raindrops directory Processing created for this program.

Checking In

Submit your solutions to the lab exercises using your appropriate submission environment:

You must submit both exercises (i.e., the aboutMe questions in the aboutMe directory and the lab program and output in the lab01 directory).

Don't forget to log off of your machine when you are finished.