By: Tamil Selvan Printer Friendly Format
The Graphics class also supports the drawing of arcs. To draw an arc, you must specify six parameters. These parameters are the four quantities that define the arc's bounding rectangle, its start angle, and its end angle. The bounding rectangle is defined by the same four parameters required for rectangles.
The drawing routine traces the arc along a path from the start angle to the end angle in a counterclockwise direction. Angle 0 degrees is along the positive x-axis of the coordinate plane. Like other geometric figures, arcs can be drawn in outline mode or fill mode. Arcs can be drawn in outline or in filled form, like rectangles.
Demonstrates the drawing of arcs using the Graphics
public class ArcDemo extends Canvas implements CommandListener
public void paint(Graphics g)
int width = getWidth();
int height = getHeight();
g.drawArc(5, 5, 80, 40, 90, 300);
g.fillArc(5, 60, 80, 40, 0, 250);
Notice that the second arc is filled and that it was created using the fillArc() method instead of the drawArc() method.
Most Viewed Articles (in J2ME )
Latest Articles (in J2ME)
Comment on this tutorial
- Data Science
- Cloud Computing
- Java Beans
- Mac OS X
- Office 365
- Tech Reviews