Program:
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package DrawingGeometricPrimitives;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.RenderingHints;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.awt.geom.Arc2D;
import java.awt.geom.CubicCurve2D;
import java.awt.geom.QuadCurve2D;
import javax.swing.JApplet;
import javax.swing.JFrame;
/**
*
* @author abdul
*/
public class CubicCurveSegment extends JApplet{
int x1 = 5;
int y1 = 100;
int x2 = 55;
int y2 = 100;
int x1Lengkung = 10;
int y1Lengkung = 5;
int x2Lengkung = 40;
int y2Lengkung = 150;
//frame
static int wFrame =300;
static int hFrame = 300;
@Override
public void paint(Graphics g ){
Graphics2D g2 = (Graphics2D) g;
//Controlling Rendering Quality
RenderingHints rh = new RenderingHints(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
g2.setRenderingHints(rh);
g2.draw(new CubicCurve2D.Double(x1, y1, x1Lengkung, y1Lengkung,x2Lengkung,y2Lengkung,x2,y2));
}
public static void main(String[] args){
JFrame f = new JFrame("CubicCurve2D");
f.addWindowListener(new WindowAdapter() {
@Override
public void windowClosing(WindowEvent e){
System.exit(0);
}
});
JApplet applet = new CubicCurveSegment();
f.getContentPane().add(applet);
f.pack();
f.setSize(wFrame, hFrame);
f.setVisible(true);
}
}
Tidak ada komentar:
Posting Komentar