01-11-2012, 02:05 PM
Graphics
Graphics.ppt (Size: 80 KB / Downloads: 23)
Course Updates & Notices
Pre-Computer Science Pizza Feed
Share your opinions with Dr. Quinn
Monday, January 31, @ 5:30 PM
Covell Hall, Room 216
Schedule Change
Program #2 is due Next Friday 2/4
Some changes to the assignment
Quiz #3 is next Wednesday 2/2
Guest Lecture Friday 2/4
The Java Graphics System
Java provides a set of graphic commands that allow you, the programmer to:
Display graphical shapes on the screen
size shape location are under programmers control
Display strings
size, font, style are under programmers control
Display images
Color these objects
Move these objects
Coordinate Systems
Java’s coordinate system is not like the coordinate system you will use in physics and general math classes
The Origin is in the upper left hand corner
X increases to the right
Y increases downward
The dimensional unit is a pixel
How big is a pixel?
Drawn and Filled Shapes
Drawn and Filled Shapes
Java lets you draw lines and shapes
Java shape drawing methods come in two styles
those where the outline only is shown
drawShape() draw(shapeClass)
those where the center is filled
fillShape() fill(shapeClass)
Java provides the ability to display predefined images
Java provides the ability to display widgets
Displaying Things
First we need a Graphics context
That portion of the screen to draw upon
How do we obtain a graphics context?
We get one as the argument to paint()
Be careful about passing the graphics context around,
it may not always be 'in context'
Java is state driven
Things tend to stay they way they are until they are changed
Once we set a color it will stay that way
Squares & Negative Numbers
Square
Width and the height are the same size.
Aspect ratio?
It is possible for the width or the height to be negative.
This makes the point you specify with first two arguments lie on some other corner than the upper left.
Most browsers will not draw this