Package org.zkoss.canvas

Examples of org.zkoss.canvas.Path


public class Shapes {
 
  // TODO: add more shapes like circle, etc
 
  public static Path nGon(double r, int n){
    Path p = new Path().moveTo(r, 0);
    for(int i=1; i<n+1; i++){
      double arg = Math.PI * (1.5 + (2.0*i)/n);
      p.lineTo(r + r * Math.cos(arg), r + r * Math.sin(arg));
    }
    p.closePath();
    return p;
  }
View Full Code Here


 
  // TODO: add nStar given by two radius
 
  public static Path nStar(double r, int n, double theta){
    // TODO: fix algorithm
    Path p = new Path().moveTo(r, 0);
    double r2 = r * Math.sin(Math.PI*theta/360) / Math.sin(Math.PI*(theta/360 + 2.0/n));
   
    for(int i=1; i<n+1; i++){
      double arg1 = Math.PI * (1.5 + (2.0*i)/n);
      double arg2 = arg1 - Math.PI/n;
      p.lineTo(r + r2 * Math.cos(arg2), r + r2 * Math.sin(arg2));
      p.lineTo(r + r * Math.cos(arg1), r + r * Math.sin(arg1));
    }
   
    p.closePath();
    return p;
  }
View Full Code Here

    double p3X = 0.5 * size;
    double p3Y = midYC;
    double p4X = 0.04 * size;
    double p4Y = midY;
   
    Path p = new Path().moveTo(p1X, p1Y)
      .curveTo(p1X + ctrp1X, p1Y + ctrp1Y, p2X + ctrp2X, p2Y + ctrp2Y, p2X, p2Y)
      .curveTo(p2X + ctrp3X, p2Y + ctrp3Y, p3X + ctrp4X, p3Y + ctrp4Y, p3X, p3Y)
      .curveTo(p3X - ctrp4X, p3Y + ctrp4Y, p4X - ctrp3X, p4Y + ctrp3Y, p4X, p4Y)
      .curveTo(p4X - ctrp2X, p4Y + ctrp2Y, p1X - ctrp1X, p1Y + ctrp1Y, p1X, p1Y)
      .closePath();
View Full Code Here

TOP

Related Classes of org.zkoss.canvas.Path

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.