Please keep the following things in mind as you do the lab exercises in this course:
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.
Do the following things on your development system:
cs108
);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.
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.
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:
.pde
extension). Make it a practice of storing your PDE files in separate folders for each lab.setup()
, which Processing calls once at the very
beginning to set the size of the output panel, and draw()
, which Processing calls
repeatedly to specify what to do on each step (frame) of the animation.size(width, height)
- This method is called
in the setup() method and sets the size of the output window in pixels (i.e., points of light on
the screen) using this statement with different values for width
and
height
. Here, the statement creates an output panel that is 300
pixels by 300 pixels.fill(redIntensityValue, greenIntensityValue,
blueIntensityValue, transparencyLevel)
- This method sets the
color of the next figure to the specified mixture of red, green and blue light intensities. The
intensity values range from 0 (black) to 255 (white).ellipse(centerXCoordinate, centerYCoordinate,
ellipseWidth, ellipseHeight)
- This method draws an ellipse at the
specified location and size. The values are specified in pixels.random(maximumValue)
method to compute random numbers between 0 and maximumValue.One good way to learn programming is to experiment (or shall we say play) with existing programs.
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:
rect()
method).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.
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.