|
Graphics commands | |
![]() |
Writing on the graphics screen g.drawString("Hello World",60, 30); To change fonts g.setFont(new Font("Ariel", Font.BOLD, 20));
|
![]() |
Example: |
![]() |
Rectangles g.drawRect(50,
30,150,60); Square - if width and
height are the same |
![]() |
Diagonal
lines Vertical
line - keep x's the
same Horizontal Line - keep y's the
same |
![]() |
Circles - if width and height are the same g.drawOval(150, 130, 60,
60); Ellipses g.drawOval(200, 50,20,
60); |
![]() |
Rectangles with the rounded corners g.drawRoundRect( 50, 60, 100, 80, 40, 40); or g.fillRoundRect(50, 150, 40, 90, 30, 30);
|
|
Arc for location or length of degrees refer to the degree wheel below g.drawArc( 50, 60, 40,40, 45, 180); or for a sector g.fillArc(120, 60, 50, 50, 180,90);
|
![]() |
Polygons are many sided figures - good for triangles, non-rectangluar quadrilaterals, pentagons, etc. Here is sample: - note we are moving around the figure Polygon trap = new
Polygon(); |
|
|
Additional commands - these do NOT belong to the paint method - put in the init method:
setSize(300,200); |
|
Here are some HTML colors - CLICK |
Examples of using these : g.setColor(new Color(60, 90,160));
|