CS 121 Lecture 13: Drawing Shapes

23 views3 pages

Document Summary

The graphics class: contains various methods that allow you to draw shapes, lines, rectangles & ovals: defined in the java. awt package. Graphics class methods: void drawline(int x1, int y1, int x2, int y2) paints a line from point (x1, y1) to point (x2, y2), void drawrect(int x, int y, int width, int height) . Paints a rectangle w/ upper left corner (x, y) & dimensions width & height: void drawoval(int x, int y, int width, int height) . The arc starts at startangle & extends for a distance defined by arcangle: void fillrect(int x, int y, int width, int height) All of these methods rely on the java coordinate system. Point (0,0) is in the upper-left corner, such that x values get larger as we move to the right & y values that get larger as we move down. Any shapes drawn at coordinates that are outside the visible area won"t be seen.

Get access

Grade+
$40 USD/m
Billed monthly
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
10 Verified Answers
Class+
$30 USD/m
Billed monthly
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
7 Verified Answers

Related Documents