import android.graphics.Point;  /**  *   * @author http://blog.csdn.net/arui319  *  */  public class Bezier {      private static final float AP = 0.5f;      private Point[] bPoints;      /**      * Creates a new Bezier curve.      *       * @param points      */      public Bezier(Point[] points) {          int n = points.length;          if (n < 3) {              // Cannot create bezier with less than 3 points              return;          }          bPoints = new Point[2 * (n - 2)];          double paX, paY;          double pbX = points[0].x;          double pbY = points[0].y;          double pcX = points[1].x;          double pcY = points[1].y;          for (int i = 0; i < n - 2; i++) {              paX = pbX;              paY = pbY;              pbX = pcX;              pbY = pcY;              pcX = points[i + 2].x;              pcY = points[i + 2].y;              double abX = pbX - paX;              double abY = pbY - paY;              double acX = pcX - paX;              double acY = pcY - paY;              double lac = Math.sqrt(acX * acX + acY * acY);              acX = acX / lac;              acY = acY / lac;              double proj = abX * acX + abY * acY;              proj = proj < 0 ? -proj : proj;              double apX = proj * acX;              double apY = proj * acY;              double p1X = pbX - AP * apX;              double p1Y = pbY - AP * apY;              bPoints[2 * i] = new Point((int) p1X, (int) p1Y);              acX = -acX;              acY = -acY;              double cbX = pbX - pcX;              double cbY = pbY - pcY;              proj = cbX * acX + cbY * acY;              proj = proj < 0 ? -proj : proj;              apX = proj * acX;              apY = proj * acY;              double p2X = pbX - AP * apX;              double p2Y = pbY - AP * apY;              bPoints[2 * i + 1] = new Point((int) p2X, (int) p2Y);          }      }      /**      * Returns the calculated bezier points.      *       * @return the calculated bezier points      */      public Point[] getPoints() {          return bPoints;      }      /**      * Returns the number of bezier points.      *       * @return number of bezier points      */      public int getPointCount() {          return bPoints.length;      }      /**      * Returns the bezier points at position i.      *       * @param i      * @return the bezier point at position i      */      public Point getPoint(int i) {          return bPoints[i];      }  }  

更多相关文章

  1. 代码中设置drawableleft
  2. android 3.0 隐藏 系统标题栏
  3. Android开发中activity切换动画的实现
  4. Android(安卓)学习 笔记_05. 文件下载
  5. Android中直播视频技术探究之—摄像头Camera视频源数据采集解析
  6. 技术博客汇总
  7. android 2.3 wifi (一)
  8. AndRoid Notification的清空和修改
  9. Android中的Chronometer

随机推荐

  1. android的style控制Theme
  2. Android(安卓)Studio
  3. android使用全局变量的两种方法
  4. Android(安卓)UI开发第二十篇——仿launc
  5. Android的绘制文本对象FontMetrics的介绍
  6. Android(安卓)-- 再来一发Intent
  7. 移动安全之Android安全检测工具大全
  8. TabHost 置于底部 顶部的方法
  9. Android(安卓)调用相册 拍照 实现系统控
  10. Android中解析xml文件的接口