[wadalabfont-kit] / java / Bezier.java  

Annotation of /java/Bezier.java

Parent Directory | Revision Log

Revision: 1.1 - (view) (download) (as text)

1 : ktanaka 1.1 import java.util.*;
2 :    
3 :     public class Bezier extends OutlineComponent{
4 :     Point p0,p1,p2,p3;
5 :     public Bezier(Point p0,Point p1,Point p2,Point p3){
6 :     this.p0=p0; this.p1=p1; this.p2=p2; this.p3=p3;
7 :     }
8 :     public Bezier[] divide(){
9 :     Bezier[] ret=new Bezier[2];
10 :     Point midp=p0.inter(p3,0.5).inter(p1.inter(p2,0.5),0.75);
11 :     ret[0]=new Bezier(p0,p0.inter(p1,0.5),
12 :     p0.inter(p2,0.5).inter(p1,0.5),midp);
13 :     ret[1]=new Bezier(midp,p3.inter(p1,0.5).inter(p2,0.5),
14 :     p3.inter(p2,0.5),p3);
15 :     return ret;
16 :     }
17 :     public void render(Vector ret,double limit){
18 :     ret.addElement(p0);
19 :     if(p0.distance(p3)<limit){
20 :     ret.addElement(p3);
21 :     }
22 :     else{
23 :     Bezier[] div=divide();
24 :     div[0].render(ret,limit);
25 :     div[1].render(ret,limit);
26 :     }
27 :     }
28 :     }

ktanaka

Powered by ViewCVS 1.0-dev

ViewCVS and CVS Help