7
Agenda For Feb 16 1. Discussion (Assignments & Rubric) 2. PowerPoint Presentation (Drawing Basic Shapes). 4. Read Unit 3 carefully (pages 15 - 20) then do: Sec 3.1 and 3.2 Mastery Questions (on pages 18 & 19) Unit 3 Unit Exercises (on page 20). " When you put a date on your dream, it becomes a goal. When you aim for the goal, it becomes a challenge. When you beat the challenge, the reward is success. To have success... you need a dream..." Copyright © 2004 Raja Akhtar 3. Finish both Unit 2 Exercises & Assignment 2. Hand in all written questions. I will be coming around today to check you off for Assignment # 2 (Applet). 5. If you finish 1 - 4 go on to Unit 4 & try all Mastery Questions.

Agenda For Feb 16 1. Discussion (Assignments & Rubric) 2. PowerPoint Presentation (Drawing Basic Shapes). 4.Read Unit 3 carefully (pages 15 - 20) then

Embed Size (px)

Citation preview

Page 1: Agenda For Feb 16 1. Discussion (Assignments & Rubric) 2. PowerPoint Presentation (Drawing Basic Shapes). 4.Read Unit 3 carefully (pages 15 - 20) then

Agenda For Feb 161. Discussion (Assignments & Rubric)

2. PowerPoint Presentation (Drawing Basic Shapes).

4. Read Unit 3 carefully (pages 15 - 20) then do:

• Sec 3.1 and 3.2 Mastery Questions (on pages 18 & 19)

• Unit 3 Unit Exercises (on page 20).

" When you put a date on your dream, it becomes a goal. When you aim for the goal, it becomes a challenge. When you beat the challenge, the reward is success. To have success... you need a dream..."Copyright © 2004 Raja Akhtar

3. Finish both Unit 2 Exercises & Assignment 2. Hand in all written questions. I will be coming around today to check you off for Assignment # 2 (Applet).

5. If you finish 1 - 4 go on to Unit 4 & try all Mastery Questions.

Page 2: Agenda For Feb 16 1. Discussion (Assignments & Rubric) 2. PowerPoint Presentation (Drawing Basic Shapes). 4.Read Unit 3 carefully (pages 15 - 20) then

Java Coordinate System

The Java coordinate system is a little different from the one you are used to. In Java the origin (0,0) is located at the top left-hand corner of your applet. As the value of x increase the paint brush will move across the applet from left to right. As the value of y increases the paint brush will move down the applet. An x value greater than the width of the applet will run you off the screen and a y value greater than the height of the applet will also run you off the screen.

Where do you go to change the dimensions of your Applet?

Page 3: Agenda For Feb 16 1. Discussion (Assignments & Rubric) 2. PowerPoint Presentation (Drawing Basic Shapes). 4.Read Unit 3 carefully (pages 15 - 20) then

The Graphics variable “screen” contains many drawing methods that we will be using. On page 21 (in the box at the bottom) there is a comment that reads “declare a Graphics variable”. Please disregard this comment and all others like it in the text book. You don’t need to declare a Graphics variable here because it is already present in the header of the paint function. The drawing methods that we will be using are:

Basic Methods of the Graphics Class

• drawString (“text goes here”, x-coordinate, y-coordinate);

• drawLine (x-start, y-start, x-end, y-end);

• drawRect (x-TopLeft, y-TopLeft, width, height);

• drawRoundRect (x-TopLeft, y-TopLeft, width, height, r1, r2);

• drawOval (x-TopLeft, y-TopLeft, width, height);

• drawArc (x-TopLeft, y-TopLeft, width, height, startDeg, endDeg);

Page 4: Agenda For Feb 16 1. Discussion (Assignments & Rubric) 2. PowerPoint Presentation (Drawing Basic Shapes). 4.Read Unit 3 carefully (pages 15 - 20) then

Drawing Rectangles & Ovals

screen.drawRect (0, 0, 50, 20);

screen.drawRoundRect (10, 40, 80, 40, 10, 10);

20

50(0,0)

40

80

(10,40) level of roundness

Page 5: Agenda For Feb 16 1. Discussion (Assignments & Rubric) 2. PowerPoint Presentation (Drawing Basic Shapes). 4.Read Unit 3 carefully (pages 15 - 20) then

Drawing Arcs

screen.drawArc (?, ?, ?, ?, ?, ?);

90 degrees

270 degrees

0 degrees180 degrees

(50,50) (80,50)

(80,60)

To draw an Arc you first have to specify an Oval and then specify (using angles) what part of the oval you wish to draw.

screen.drawArc (50, 50, 30, 10, 0, 90);

Page 6: Agenda For Feb 16 1. Discussion (Assignments & Rubric) 2. PowerPoint Presentation (Drawing Basic Shapes). 4.Read Unit 3 carefully (pages 15 - 20) then

public class myApplet extends Applet { // variable section (declare your variables here) Graphics screen; // you can omit this line

// initialization method public void init() {

}

// this method handles all the painting to the screen public void paint(Graphics screen) { // drawing instruction go here screen.drawRect (0, 0, 50, 20); }}

Your Applet Program With Comments

Page 7: Agenda For Feb 16 1. Discussion (Assignments & Rubric) 2. PowerPoint Presentation (Drawing Basic Shapes). 4.Read Unit 3 carefully (pages 15 - 20) then

screen.drawRect (0, 0, 50, 20);

screen.drawRoundRect (30, 40, 75, 45, 25, 25);

(30, 40)