[wadalabfont-kit] / java / Renderer.java  

View of /java/Renderer.java

Parent Directory | Revision Log
Revision: 1.2 - (download) (as text) (annotate)
Thu Jan 4 10:23:56 2001 UTC (23 years, 10 months ago) by ktanaka
Branch: MAIN
CVS Tags: SNAP-20030702, SNAP-20030624, SNAP-20030630, SNAP-20040518, HEAD
Changes since 1.1: +16 -0 lines
MinchoRenderer$B$N$X$s$3$&(B
//
// Skeleton$B%G!<%?$rEO$7$F(B, $B%"%&%H%i%$%s$rJV$9(B
//
public class Renderer {
  static final boolean debug=false;
  static Point[] indexToPoints(Point[] points,int[] indices){
    int i,len=indices.length;
    Point[] ret=new Point[len];
    for(i=0;i<len;i++)
      ret[i]=points[indices[i]];
    return ret;
  }
  public Outline[] elementRenderer(Point[] points,Element element){
    int type=element.type;
    Point[] elementPoints=indexToPoints(points,element.points);
    switch(type){
    case Element.ten: 
      return ten(elementPoints,element.annotations);
    case Element.tate: 
      return tate(elementPoints,element.annotations);
    case Element.yoko: 
      return yoko(elementPoints,element.annotations);
    case Element.migiue: 
      return migiue(elementPoints,element.annotations);
    case Element.hidari: 
      return hidari(elementPoints,element.annotations);
    case Element.tatehidari: 
      return tatehidari(elementPoints,element.annotations);
    case Element.migi: 
      return migi(elementPoints,element.annotations);
    case Element.kozato: 
      return kozato(elementPoints,element.annotations);
    case Element.tatehane: 
      return tatehane(elementPoints,element.annotations);
    case Element.tsukurihane: 
      return tsukurihane(elementPoints,element.annotations);
    case Element.sanzui: 
      return sanzui(elementPoints,element.annotations);
    case Element.kokoro: 
      return kokoro(elementPoints,element.annotations);
    case Element.tasuki: 
      return tasuki(elementPoints,element.annotations);
    case Element.magaritate: 
      return magaritate(elementPoints,element.annotations);
    case Element.kagi: 
      return kagi(elementPoints,element.annotations);
    case Element.shin_nyuu: 
      return shin_nyuu(elementPoints,element.annotations);
    case Element.hira_long: 
      return hira_long(elementPoints,element.annotations);
    case Element.hira_circle: 
      return hira_circle(elementPoints,element.annotations);
    case Element.outline: 
      return outline(elementPoints,element.annotations);
    }
    return null;
  }
  public Outline[] ten(Point[] points,ElementAnnotation[] annotations){
    return null;
  }
  public Outline[] tate(Point[] points,ElementAnnotation[] annotations){
    return null;
  }
  public Outline[] yoko(Point[] points,ElementAnnotation[] annotations){
    return null;
  }
  public Outline[] migiue(Point[] points,ElementAnnotation[] annotations){
    return null;
  }
  public Outline[] hidari(Point[] points,ElementAnnotation[] annotations){
    return null;
  }
  public Outline[] tatehidari(Point[] points,ElementAnnotation[] annotations){
    return null;
  }
  public Outline[] migi(Point[] points,ElementAnnotation[] annotations){
    return null;
  }
  public Outline[] kozato(Point[] points,ElementAnnotation[] annotations){
    return null;
  }
  public Outline[] tatehane(Point[] points,ElementAnnotation[] annotations){
    return null;
  }
  public Outline[] tsukurihane(Point[] points,ElementAnnotation[] annotations){
    return null;
  }
  public Outline[] sanzui(Point[] points,ElementAnnotation[] annotations){
    return null;
  }
  public Outline[] kokoro(Point[] points,ElementAnnotation[] annotations){
    return null;
  }
  public Outline[] tasuki(Point[] points,ElementAnnotation[] annotations){
    return null;
  }
  public Outline[] magaritate(Point[] points,ElementAnnotation[] annotations){
    return null;
  }
  public Outline[] kagi(Point[] points,ElementAnnotation[] annotations){
    return null;
  }
  public Outline[] shin_nyuu(Point[] points,ElementAnnotation[] annotations){
    return null;
  }
  public Outline[] hira_long(Point[] points,ElementAnnotation[] annotations){
    return null;
  }
  public Outline[] hira_circle(Point[] points,ElementAnnotation[] annotations){
    return null;
  }
  public Outline[] outline(Point[] points,ElementAnnotation[] annotations){
    return null;
  }
  // p0 $B$H(B p1 $B$N4V$rI}(B width $B$GD>@~FyIU$1(B
  public Outline[] line2(Point p0,Point p1,double width){
    Point v0=p1.minus(p0).rot270().normal(width);
    Outline[] ret=new Outline[2];
    OutlineComponent[] right=new OutlineComponent[1];
    right[0]=new Line(p0.plus(v0),p1.plus(v0));
    OutlineComponent[] left=new OutlineComponent[1];
    left[0]=new Line(p0.minus(v0),p1.minus(v0));
    ret[0]=new Outline(right);
    ret[1]=new Outline(left);
    return ret;
  }
  //
  public Outline curveSub(Point p0, Point p1, Point p2, Point p3,
                          double r0, double r1){
    OutlineComponent[] ret=new OutlineComponent[1];
    Point p12=Point.cross(p0,p1,p2,p3);
    if(debug)
      System.out.println("cross("+p0+","+p1+","+p2+","+p3+")="+p12);
    ret[0]=new Bezier(p0,p0.inter(p12,r0),p3.inter(p12,r1),p3);
    return new Outline(ret);
  }
  // p0, p1, p2$B$N4V$r6J@~$G7k$V(B
  // p0 $B$G$OI}(B w0, p2$B$G$OI}(Bw3
  // p0$B$+$i(B p1$B$K(Br0(0$B$+$i(B1)$B?J$s$@$H$3$m$GI}(B w1
  // p2$B$+$i(B r1(0$B$+$i(B1)$BLa$C$?$H$3$m$GI}(B w2$B$H$J$k(B
  // $B$?$@$7(B, $B30B&$N%+!<%V$HFbB&$N%+!<%V$N(B Bezier$B@)8fE@$NHfN($,(B
  // $BF1$8$K$J$k$h$&$K(B
  public Outline[] curve2(Point p0,Point p1,Point p2,
                         double r0,double r1,
                         double w0,double w1,double w2,double w3){
    Point p01=p0.inter(p1,r0),p12=p2.inter(p1,r1);
    Outline[] ret=new Outline[2];
    Point v0=p1.minus(p0).rot270(), v2=p2.minus(p0).rot270();
    ret[0]=curveSub(p0.plus(v0.normal(w0)),
                    p0.inter(p1,r0).plus(v0.normal(w1)),
                    p2.inter(p1,r1).plus(v2.normal(w2)),
                    p2.plus(v2.normal(w3)),
                    r0,r1);
    ret[1]=curveSub(p0.minus(v0.normal(w0)),
                    p0.inter(p1,r0).minus(v0.normal(w1)),
                    p2.inter(p1,r1).minus(v2.normal(w2)),
                    p2.minus(v2.normal(w3)),
                    r0,r1);
    return ret;
  }
  public  Outline[] fitSample(Outline[] sample,Point p0, Point p1,double ratio){
    Point p2=sample[0].firstPoint();
    Point p3=sample[0].lastPoint();
    double theta1=p3.minus(p2).theta();
    double theta2=p1.minus(p0).theta();
    double len01=p0.distance(p1),len23=p2.distance(p3);
    double r1=len01/len23;
    Outline[] ret=new Outline[2];
    ret[0]=sample[0].plus(p2.neg()).rot(-theta1).times(r1).timesY(ratio).rot(theta2).plus(p0);
    ret[1]=sample[1].plus(p2.neg()).rot(-theta1).times(r1).timesY(ratio).rot(theta2).plus(p0);
    return ret;
  }
}





ktanaka

Powered by ViewCVS 1.0-dev

ViewCVS and CVS Help