Graphics

From MyWiki
Revision as of 17:47, 17 November 2014 by George2 (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Java AWT
g.drawLine(35, 45, 75, 95);
g.drawRect(35, 45, 25, 35);
g.drawRoundRect(35,45,25,35,10,10);
g.drawOval(25, 35, 25, 35);
g.drawArc(35, 45, 75, 95, 0, 90);

int [ ] x = {20, 35, 50, 65, 80, 95};
int [ ] y = {60, 105, 105, 110, 95, 95};
g.drawPolygon(x, y, 6);
drawPolygon(int x[ ], int y[ ], int n)
Used to draw a polygon created by n line segments. The command will close the polygon. (x-coordinates go in one array with accompanying y-coordinates in the other)
g.drawString("Java is cool!", 40, 70);
drawString(String str, int x, int y);

Filled Rectangle
g.setColor(Color.orange);

g.setColor(Color.orange);
g.fillRect(35,45,75,95);
g.setColor(Color.black);
g.drawRect(35, 45, 75, 95);