CS 32 (Under Construction)
Computer Graphics (Amherst College)
All Material Copyright (C) Dr. William T. Verts, 1996
These files are for use by students in CS32 (Amherst College) Spring semester
1996. While they may be downloaded and used by anyone, as far as I
care (as long as the files themselves are left intact with all copyright
information, etc.), they may not be particularly meaningful to anyone
outside of the graphics class and its associated "Little Language" graphics
project.
Final Exam
Added May 10, 1996
Here is a link to review topics for final exam,
and material expected to be submitted with your projects.
By request, here is a link to a site full of shareware, including the
PKUNZIP program for unpacking the archives that I have placed on
this page. These are the steps you should follow:
- Link to WWW.SHAREWARE.COM
- Change the search to DOS software
- Search for "pkz204g.exe"
- Download it
- Run it (it is a self-extracting archive, containing PKUNZIP.EXE)
Font File containing stroke definitions
for characters 32..126 only
ASCII.FNT (.ZIP format, 1K)
ASCII.GIF (.GIF image of the defined characters,
10K)
Font File containing stroke definitions for characters 0..255
(entire IBM PC character set)
DATAFONT.FNT (.ZIP format, 3K)
DATAFONT.GIF (.GIF image of the defined characters,
16K)
The "Little Language" programs on the assignment handout
A_TEST.PRG & B_TEST.PRG (.ZIP format, 1K)
A_TEST.GIF (Result of A_TEST.PRG, 5K)
B_TEST.GIF (Result of B_TEST.PRG, 2K)
B_TEST2.GIF (Result of B_TEST.PRG, 3K,
showing only the outlines of the wide lines as rectangles)
This is a Pascal Unit that may help you to create your "library"
routines (the base layer of your project). It contains a number
of types, procedures, and functions pertinent to the graphics
"Little Language", including several ways of computing distances
between points (both 2D and 3D), matrix multiplication, parametric
representations of 2D and 3D lines, and so on. Please feel free
to extract and use any parts that are useful to you. The archive
is about 3K, but unpacks to 16K, and tab stops are assumed to be
every 8 spaces.
STANDARD.ZIP (.ZIP archive, 3K,
contains STANDARD.PAS, 16K)
Six Pascal source files illustrating the differences between
object oriented programming and standard programming, using
a simple stack of integers as the abstract data type being
modeled. The file is 4K, but unpacks to 10K of source (tab
characters are used throughout, and it is assumed that tab
stops are every 8 spaces).
STACKS.ZIP (.ZIP archive, 4K)
The source files are:
- STACK_A.PAS Standard Version, Driver Program
- STACKS1A.PAS Standard Version, Unit using Arrays
- STACKS2A.PAS Standard Version, Unit using Linked Lists
- STACK.PAS Object Oriented Version, Driver Program
- STACKS1.PAS Object Oriented Version, Unit using Arrays
- STACKS2.PAS Object Oriented Version, Unit using Linked Lists
Polygon Fill Sample Program
Procedure Main
Screen 100 100
Window 0 99 99 0
Viewport_All
Clear_Poly
Vertex 10 10
Vertex 60 20
Vertex 80 80
Vertex 70 90
Vertex 30 90
Vertex 30 80
Vertex 60 70
Vertex 60 40
Vertex 50 60
Vertex 30 60
Close_Poly
Color 255 0 0
Fill
Color 255 255 0
Stroke
End
POLYGON.GIF (.GIF of the polygon fill
from the program just above, 2K)
Link to Dr. Bill's Notes on Polygon Fills
A Sample "Little Language" Program for generating a Printed Circuit
Board
The image in the .GIF will appear to be "backwards". Refer to the "Little
Language" program for why this is so. The program is quite lengthy and
complex, so you might want to use it as a benchmark for your own testing.
It uses text scaled so that it comes out mirrored, windows with yMin and
yMax reversed (and xMin and xMax reversed in one example), many procedure
calls, and use of TRANSLATE and PERFORM to implement step-and-repeat.
DEBOUNCE.GIF (.GIF of the output, 5K)
DEBOUNCE.ZIP (.ZIP of the program and
the .GIF, 10K)
This set of files was derived from a digital terrain model of a US
Geological Survey 7.5 minute quadrangle (Corvallis, Oregon). I wrote
a program to turn the data (46 rows by 33 columns) into a "Little
Language" program full of polygon fills. This filter program used the
simple orthographic projection described in class, painting each
polygon as a slice horizontally through the terrain from slice furthest
away to slice nearest the eye. In addition, the right hand edge values
were treated as a separate polygon fill to make a nice side to the
surface. The .GIF image uses a very small screen (241x106), and as a
consequence the terrain is fairly coarse. The generating .PRG file
is about 2000 lines of "Little Language" commands, but all the screen,
window, and viewport controls are at the top for easy modification
(e.g., increase the screen size to 482x212 to quadruple the graphics
area while preserving the aspect ratio).
SURFACE.GIF (.GIF image, 3K)
SURFACE.ZIP (10K .ZIP containing
both the 3K SURFACE.GIF and the generating 45K SURFACE.PRG
"Little Language" program)
Palette Handling (April 10, 1996)
Link to Dr. Bill's Notes on Palette Handling
These are some notes on handling Palettes that I put in on
April 10th. Notes include sample code and techniques
for generating monochrome, 16 color, and 256 color palettes.
More on Palette Handling (April 12, 1996)
Link to More of Dr. Bill's Notes on Colors
These new notes include a computational way of converting a 24 bit
color to a VGA 1-of-16 color, and a way of generating a "random"
256 color palette that approximates what is found in most .GIF files.
A Sample "Little Language" Program that moves Viewports
(April 15,1996)
This is a sample program that illustrates what happens when
you plot the same graphics over and over again in different
viewports. The window (world coordinates) is square, and
some of the viewports are square, but several viewports are
not square, illustrating how the window-to-viewport
mapping does not have to have a strict 1:1 aspect ratio.
Also, two of the viewports overlap.
VIEWPORT.GIF (2K)
VIEWPORT.ZIP (3K .ZIP archive,
containing both the 1K source of the little language program and
the 2K .GIF image).
24 Bit .BMP File Format (April 19, 1996)
This is a link to a page containing a description and
sample Pascal code for writing out 24 bit images as
Windows .BMP files. There will be a later entry on
writing out 1, 4, and 8 bit per pixel .BMP files, but
those require palettes.
Link to Dr. Bill's Notes on 24 bit .BMP
An Essay on "Little Endian" versus "Big Endian" (April 19, 1996)
This is a link to an essay on the differences between the "Little
Endian" byte order and the "Big Endian" byte order, based on the
discussion that we had in class on Friday the 19th. I figured
that maybe not everybody was clear on the differences, or why
it mattered to us.
Link to Dr. Bill's Essay on Endian Order
A "Little Language" Map of Massachusetts (April 21, 1996)
This is a file that I extracted from some cartographic data that
I had sitting around since 1986 (I never throw anything out). It
is a very simple file, consisting of mostly Move_To and Line_To
commands, and is about 350 lines in length. The result will be
an outline of Massachusetts, with county boundaries, and with
a few of the islands shown.
MASS.GIF (1K .GIF image)
MASS.ZIP (3.5K .ZIP, containing 1K .GIF and 9K .PRG)
Does anybody actually look at this stuff? Do you find it useful?
Please email me when you
come around to look at it. Thanks!
Using the VGA in 320x200 256-Color mode (April 28, 1996)
This document is mostly for the people using MS-DOS to write
their project, but is useful for everyone in the class to understand
some issues of optimizing code to the hardware and learning how real
palettes are implemented. The sample Pascal code in the .ZIP file
also contains versions of Bresenham's line and circle routines, as
well as a working .EXE demo showing some of the "stupid VGA tricks"
we can write to get fast animation.
Link to Dr. Bill's Notes on VGA 320x200 256-Color
Mode
Multiple Frame-Based Animation in VGA 320x200 Mode (April 28, 1996)
Here is another program that uses the VGA 320x200 256-color mode. In this
program, off-screen video frames are allocated (as many as memory allows),
separate images are plotted and saved in those frames, then the frames
are copied quickly over and over into the VGA frame buffer to animate
the display. The .ZIP archive below contains:
- (6K) The Pascal source code of the animator ANIMATE.PAS,
- (13K) the Pascal source code of the VGA driver unit VGA_320.PAS,
- (11K) and the DOS executable file ANIMATE.EXE.
ANIMATE.ZIP (12K)
Screen Drivers for all you "Code Warriors" (April 30, 1996)
The link below is to a file that contains a test program written in
Code-Warrior Pascal that plots graphics on the Power PC's using
Mac QuickDraw graphics. I have to say that I don't understand all of
the "magic incantations" myself, as I got a lot of the code by
copying the appropriate material from examples in the Code Warrior
examples folders, but it seems to work OK. This program plots
rectangles in random colors and positions in a window that is
50 pixels in from all four screen margins, and continues to do so
until the mouse button is clicked. I think you can extract most of
what you need for the "Little Language" project from this example.
CODE_WAR.ZIP (1.5K .ZIP containing 6.5K Pascal
program)
Back to Dr. Bill's Classes
Back to Dr. Bill's Home Page