martes, 2 de octubre de 2012
CURVAS
import javax.swing.*;
import java.awt.*;
import java.awt.geom.*;
public class CubicCurve2D1 extends JFrame {
private CubicCurve2D Shape1;
private CubicCurve2D Shape2;
private float X1;
private float Y1;
private float X2;
private float Y2;
private float CX1;
private float CY1;
private float CX2;
private float CY2;
private double DX1;
private double DY1;
private double DX2;
private double DY2;
private double DCX1;
private double DCY1;
private double DCX2;
private double DCY2;
public CubicCurve2D1 () {
X1 = 10.F;
Y1 = 20.F;
X2 = 150.F;
Y2 = 130.F;
CX1 = 20.F;
CY1 = 90.F;
CX2 = 140.F;
CY2 = 100.F;
DX1 = 160.;
DY1 = 20.;
DX2 = 230.;
DY2 = 40.;
DCX1 = 160.;
DCY1 = 120.;
DCX2 = 240.;
DCY2 = 90.;
Shape1 = new CubicCurve2D.Float (X1, Y1, CX1, CY1, CX2, CY2, X2, Y2);
Shape2 = new CubicCurve2D.Double ();
Shape2.setCurve (DX1, DY1, DCX1, DCY1, DCX2, DCY2, DX2, DY2);
}
public void paint (Graphics g) {
Graphics2D g2D;
g2D = (Graphics2D) g;
g2D.setColor (Color.cyan);
g2D.drawLine ((int)X1, (int)Y1, (int)CX1, (int)CY1);
g2D.drawLine ((int)X2, (int)Y2, (int)CX2, (int)CY2);
g2D.drawLine ((int)DX1, (int)DY1, (int)DCX1, (int)DCY1);
g2D.drawLine ((int)DX2, (int)DY2, (int)DCX2, (int)DCY2);
g2D.setColor (Color.black);
g2D.draw (Shape1);
g2D.draw (Shape2);
}
}
Suscribirse a:
Enviar comentarios (Atom)
No hay comentarios:
Publicar un comentario