To Projects
IT 211 -- Project 4
Draw Two Letters
- Goal: Draw two letters using "*" characters. Write
your letter to an output file.
- Look up your letter assignments here.
- Relevant Examples: LetterH
LetterZ
French Flag
LetterHPpm
LetterZPpm
- Restriction: when drawing letters, you must use double loops for which the action only prints
one character (such as "*") at a time.
- Important: Draw a hand sketch of your letter before you start writing any code.
- Optional: If you wish, draw your letter in a .PBM or .PGM,
or .PPM image file as with the
French Flag Example. Sometimes
the file extension .PNM (Portable Any Map) is used generically to indicate that
any one of the three file formats PBM, PGM, or PPM is being used. If you
expect to obtain an A in IT 211, your Project 3 Ruby script should produce a
letter in a .PNM file.
- For a .PBM (Portable Bit Map) file, each pixel consists of 0 or 1, depending on whether the image is black or white, respectively.
The header in the first line of a PBM file is
P1 100 80
where P1 is the magic number, 100 is the image width, and 80 is the image height. Here is a complete tiny image:
P1 3 3
0 1 0
1 1 0
0 0 1
- For a .PGM (Portable Greylevel Map) file, each pixel is a number between 0 and 255 inclusive, which represents
a gray level.
The first line of the file is a header like this
P2 100 80 255
Where P2 is the magic number, 100 is the image width, 80 is the image height, and 255 is the maximum pixel value.
Here is a complete tiny image:
P2 3 3 255
230 210 32
120 89 5
255 100 0
- For a .PPM (Portable Pixel Map) file, each pixel contains the three color components red, green, and blue. Each component
is a number between 0 and 255 inclusive, which represents a color pixel.
The first line of the file is a header like this
P3 100 80 255
Where P3 is the magic number, 100 is the image width, 80 is the image height, and 255 is the maximum pixel value.
Here is a complete tiny image:
P3 3 3 255
0 0 128 0 0 128 0 0 128
0 0 128 196 196 196 0 0 128
0 0 128 0 0 128 0 0 128
Free Image Viewers for PPM Images
- Download IrfanView for Windows.
- Download ToyViewer for Mac.
Grading Breakdown
Letter 1: 60 Letter 2: 25 Source Code Comments: 10 Properly Submitted: 5