Yang terdiri dari derajat1 ,2,3,spline dan dengan titik kontrol
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package grafika_komp;
/**
*
* @author Qori
*/
import java.awt.*;
import java.awt.event.*;
import java.awt.geom.*;
public class TUGAS_3 extends Frame {
int x=300;
int y=80;
Stroke tebal = new BasicStroke(3);
Line2D derajat1=new Line2D.Double(100, 80, 300, 80);
QuadCurve2D derajat2 = new QuadCurve2D.Double(50,200,70,5,100,200);
CubicCurve2D derajat3 =new CubicCurve2D.Double(80,300,100,10,110,500,150,200);
CubicCurve2D spline=new CubicCurve2D.Double(80, 400, 150, 300, 100, 450, 300, 290);
public void paint(Graphics g) {
Graphics2D ga = (Graphics2D) g;
ga.setStroke(tebal);
ga.setPaint(Color.green);
ga.draw(derajat2);
ga.setPaint(Color.black);
ga.draw(derajat3);
ga.setPaint(Color.ORANGE);
ga.draw(derajat1);
ga.setPaint(Color.LIGHT_GRAY);
ga.draw(spline);
ga.setPaint(Color.YELLOW);
QuadCurve2D kontrol=new QuadCurve2D.Double(200, 300, x, y, 400, 300);
ga.draw(kontrol);
MouseListener mouseListener = new MouseAdapter() {
public void mouseClicked(MouseEvent ev) {
x = ev.getX();
y = ev.getY();
repaint();
}
};
addMouseListener(mouseListener);
}
public static void main(String args[]) {
Frame frame = new TUGAS_3();
frame.setTitle("TUGAS 3 = Membuat Kurva");
frame.setBackground(Color.blue);
frame.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent we) {
System.exit(0);
}
});
frame.setSize(500, 500);
frame.setVisible(true);
}
}
Tidak ada komentar:
Posting Komentar