Difference between revisions of "Graphics"

From MyWiki
Jump to: navigation, search
 
(9 intermediate revisions by the same user not shown)
Line 3: Line 3:
 
g.drawRect(35, 45, 25, 35);<br>
 
g.drawRect(35, 45, 25, 35);<br>
 
g.drawRoundRect(35,45,25,35,10,10);<br>
 
g.drawRoundRect(35,45,25,35,10,10);<br>
 +
g.drawOval(25, 35, 25, 35);<br>
 +
g.drawArc(35, 45, 75, 95, 0, 90);<br>
 +
 +
int [ ] x = {20, 35, 50, 65, 80, 95};<br>
 +
int [ ] y = {60, 105, 105, 110, 95, 95};<br>
 +
g.drawPolygon(x, y, 6);<br>
 +
drawPolygon(int x[ ], int y[ ], int n)<br>
 +
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)<br>
 +
g.drawString("Java is cool!", 40, 70);<br>
 +
drawString(String str, int x, int y);<br>
 +
<br>
 +
Filled Rectangle<br>
 +
g.setColor(Color.orange);<br>
 +
<br>
 +
g.setColor(Color.orange);<br>
 +
g.fillRect(35,45,75,95);<br>
 +
g.setColor(Color.black);<br>
 +
g.drawRect(35, 45, 75, 95);<br>
 +
<br>

Latest revision as of 17:47, 17 November 2014

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);