[wadalabfont-kit] / java / Bezier.java  

View of /java/Bezier.java

Parent Directory | Revision Log
Revision: 1.2 - (download) (as text) (annotate)
Thu Jan 4 10:23:56 2001 UTC (23 years, 4 months ago) by ktanaka
Branch: MAIN
CVS Tags: SNAP-20030702, SNAP-20030624, SNAP-20030630, SNAP-20040518, HEAD
Changes since 1.1: +17 -0 lines
MinchoRendererのへんこう瘢雹
import java.util.*;

public class Bezier extends OutlineComponent{
  Point p0,p1,p2,p3;
  public Bezier(Point p0,Point p1,Point p2,Point p3){
    this.p0=p0; this.p1=p1; this.p2=p2; this.p3=p3;
  }
  public Bezier[] divide(){
    Bezier[] ret=new Bezier[2];
    Point midp=p0.inter(p3,0.5).inter(p1.inter(p2,0.5),0.75);
    ret[0]=new Bezier(p0,p0.inter(p1,0.5),
                      p0.inter(p2,0.5).inter(p1,0.5),midp);
    ret[1]=new Bezier(midp,p3.inter(p1,0.5).inter(p2,0.5),
                      p3.inter(p2,0.5),p3);
    return ret;
  }
  public void render(Vector ret,double limit){
    ret.addElement(p0);
    if(p0.distance(p3)<limit){
      ret.addElement(p3);
    }
    else{
      Bezier[] div=divide();
      div[0].render(ret,limit);
      div[1].render(ret,limit);
    }
  }
  public OutlineComponent plus(Point point){
    return new Bezier(p0.plus(point),p1.plus(point),p2.plus(point),p3.plus(point));
  }
  public OutlineComponent rot(double theta){
    return new Bezier(p0.rot(theta),p1.rot(theta),p2.rot(theta),p3.rot(theta));
  }
  public OutlineComponent times(double ratio){
    return new Bezier(p0.times(ratio),p1.times(ratio),p2.times(ratio),p3.times(ratio));
  }
  public OutlineComponent timesY(double ratio){
    return new Bezier(p0.timesY(ratio),p1.timesY(ratio),p2.timesY(ratio),p3.timesY(ratio));
  }
  public Point firstPoint(){ return p0;}
  public Point lastPoint(){ return p3;}
  public String toString(){
    return "Bezier("+p0+","+p1+","+p2+","+p3+")";
  }
}

ktanaka

Powered by ViewCVS 1.0-dev

ViewCVS and CVS Help