Download presentation
Presentation is loading. Please wait.
Published byRafe Foster Modified over 8 years ago
1
Introductory Graphics Chapter Three
2
Computer Graphics §Full motion pictures (“Star Wars”) l animated films §Virtual reality §Games §Simulators (air craft etc.)
3
“A first Picture” §import java.awt.*; §import java.applet.Applet; §public class FirstLine extends Applet { l public void paint (Graphics g) { g.drawLine (0,0,100,100); }
4
Alter old HTML or Write New One §<applet “code = FirstLine.class” l can use same width and height…..> 0,0 0,300 300,0 100,100 300,330 START ENDING G.drawLine(0,0,100,100);
5
g.drawLine(0,0,100,100) “parameters” §doSomething( ); No parameters
6
The Paint Method §“Signiture Line” l public void paint (Graphics g) { security return Method name type Variable name
7
§Security = who can “see” modify method §void = return “nothing” this time… §paint = name of method (could be anything) §(Graphics = type variable g = name of particular variable) { begin/start of content of method
8
Methods for Drawing §Rectangles, ovals, arcs, polygons l 3D rectangles l filled shapes l polygons l rounded corners §drawArc( ) or drawOval, Rect,Line
9
drawArc ( 6 parameters) §X position §Y position §Width §Height §Starting point (360 degree of Clock) §Total Angle of Arc
10
0 degree (3:00 o’clock position 90 degree (12:00 o’clock) 180 270 degree or 6:00 o’clock position 100,200,200,150,180,90 G.drawArc() 90
11
COLORS STANDARD 13 §256 * 256 * 256 (Lots of possible) l blackbluecyan darkgray l graygreenlightgray magenta l orangepinkredwhite l yellow
12
§ g.setBackground(Color.lightgray) ; §g.setColor.red; l SOLID FIGURES §fillRect §fillArc §fillOval
13
Sequence of “Graphics” Applet §Import java.awt.*; §import java applet.Applet; l public class FirstShapes extends Applet { public void paint (Graphics g) { g.drawRect (30,30,80,40); g.drawOval(120,30,50,50); setColor(Color.black); fillRect(30,100,80,40);
14
§drawLine (30,160,130,170); §drawArc (30,180,50,50,60,40); §fillArc(120,180,50,50,60,40); §} }
15
Add some text… §G.drawString (“ Hello World “, 30, 40); Horizontal X Y position
16
Concatenation + operator §G.drawString(“Hi” + “There” + “Mike”,100,100);
17
Comments (Types) §// single line comments §/* This is l an example of a multi line comment */ l /** Special JDK comment used for manuals not in J++ JBuilder */
18
Some comments are required for this class (All programs) §Your name §What function of program §The course you are in §Other comments as needed to help explain logic of program OR add needed detail l // draws a stickman // head //legs //arms
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.