gambar geometri

/// Pertemuan k-1b:gambar geometri
// Praktikum Grafika Komputer Java2D.
//oleh : M. Guntara
//file : geo_dasar_panel3.java
//dibuat : Feb 2010
import java.awt.geom.*;
import java.awt.Graphics;
import java.awt.Graphics2D;
import javax.swing.JPanel;

public class geo_dasar_panel3 extends JPanel
{
   // draw general paths
   public void paintComponent( Graphics g )
   {
      super.paintComponent( g ); // call superclass's paintComponent

      Graphics2D g2d = ( Graphics2D ) g;

// menggambar garis
//Line2D garis=new Line2D.Double(10,10,100,50);
//g2d.draw(garis);


//menggambar  kotak

//Rectangle2D segiempat=new Rectangle2D.Double(150,10,100,50);
//g2d.draw(segiempat);

//menggambar roda depan dan belakang

Ellipse2D roda1=new Ellipse2D.Double(80,110,20,20);
Ellipse2D roda2=new Ellipse2D.Double(175,110,20,20);
g2d.draw(roda1);
g2d.draw(roda2);

//memggambar kap
Arc2D busur=new Arc2D.Double(60,80,120,70,20,140,Arc2D.CHORD);
g2d.draw(busur);

//mengamnbar bodi
GeneralPath lintas=new GeneralPath(GeneralPath.WIND_EVEN_ODD);
lintas.moveTo(50,100);
lintas.lineTo(200,100);
lintas.lineTo(260,120);
lintas.lineTo(50,120);
lintas.lineTo(50,100);

g2d.draw(lintas);

         } // end method paintComponent
} // end class geo_dasar_panel3

  • Digg
  • Del.icio.us
  • StumbleUpon
  • Reddit
  • RSS

0 komentar:

Poskan Komentar