/* * BezierApplet.java * * (C) 2004, Alex S. */ import java.awt.*; import java.util.*; public class BezierApplet extends BufferedApplet { Vector points = new Vector(); int selectedPoint = -1; /** * initialize things */ public void init(){ super.init(); } public double distance(double x1,double y1,double x2,double y2){ return Math.sqrt( (x1-x2)*(x1-x2) + (y1-y2)*(y1-y2) ); } public int hitsPoint(int x,int y){ for(int i=0;i= 4;i+=3){ double[] a = (double[])points.elementAt(i+0); double[] b = (double[])points.elementAt(i+1); double[] c = (double[])points.elementAt(i+2); double[] d = (double[])points.elementAt(i+3); GX[0] = a[0]; GX[1] = b[0]; GX[2] = c[0]; GX[3] = d[0]; GY[0] = a[1]; GY[1] = b[1]; GY[2] = c[1]; GY[3] = d[1]; Cubic xSpline = new Cubic(Cubic.BEZIER, GX); Cubic ySpline = new Cubic(Cubic.BEZIER, GY); for (double t = 0 ; t < 1 ; t += 0.01) g.drawLine( (int)xSpline.eval(t), (int)ySpline.eval(t), (int)xSpline.eval(t+0.01), (int)ySpline.eval(t+0.01) ); } g.setColor(Color.gray); for(int i=1;i