Android中使用Bezier曲线
来源:互联网 发布:h3c 把端口加入vlan 编辑:程序博客网 时间:2024/06/07 10:09
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]; } }
0 0
- Android中使用Bezier曲线
- Android中使用Bezier曲线
- android上Bezier曲线绘制
- 史上最全的贝塞尔曲线(Bezier)全解(二):Android中曲线的简单绘制
- Bezier曲线:
- bezier 曲线
- Bezier曲线
- Bezier曲线
- Android 绘制N阶Bezier曲线
- Android之贝塞尔曲线(Bezier)
- Bezier曲线在Android动画中的应用
- 如何在Direct2D中画Bezier曲线
- 使用OpenGL画三次Bezier曲线
- OpenGL中如何绘制Bezier曲线和NURBS曲线
- OpenGL中如何绘制Bezier曲线和NURBS曲线
- bezier曲线和bezier曲面
- Android简明开发教程十九:线程 Bezier曲线
- Android简明开发教程十九:线程 Bezier曲线
- Android中在屏幕上涂鸦的例子
- System.getProperties的key与value.
- Android颜色选择器
- 简单的jdbc封装+servlet的封装
- 数据结构- 快速排序
- Android中使用Bezier曲线
- C3P0配置文件解析
- WPF 去边框 自定义窗体 拖动窗体大小变化
- Eclipse 打开鼠标悬停提示功能
- 异步获取已安装程序列表(PackageManager+AsyncTask)
- 运用WindowManager,当滚动列表时显示一个类似Toast的提示(android demo)
- ExecutorCompletionService的使用和实现
- ViewFlow,一个滑动效果库
- google的NumberPicker