int genBezier(double pCont[][],double point[][])
{
double t;int tc;
tc=0;
for (t=0.0;t<=1.001;t=t+0.05){
point[tc][0]=pCont[0][0]*(1-t)*(1-t)*(1-t) + 3*pCont[1][0]*t*(1-t)*(1-t) +
3*pCont[2][0]*t*t*(1-t) + pCont[3][0]*t*t*t;
point[tc][1]=pCont[0][1]*(1-t)*(1-t)*(1-t) + 3*pCont[1][1]*t*(1-t)*(1-t) +
3*pCont[2][1]*t*t*(1-t) + pCont[3][1]*t*t*t;
tc++;
}
return(tc);
}

public void mousePressed(MouseEvent e){
//マウスのボタンが押された
match=-1;
double mpoint[]=new double[2];
//近い点を探す
mpoint[0]=e.getX();mpoint[1]=e.getY();
for(int i=0;i<4;i++){
if (dist(mpoint,pCont[i])<10.0){
match=i;//見つかった
//System.out.println("match:"+match);
break;
}
}
}
public void mouseDragged(MouseEvent e){
//マウスのドラッグがあった
if (match >= 0) {
pCont[match][0]=e.getX();
pCont[match][1]=e.getY();
}
repaint();//再表示
}