用Graphics的 drawPath 来画曲线(1)
来源:互联网 发布:nodejs 商城源码 编辑:程序博客网 时间:2024/05/16 16:10
1 用最简单的代码 画一条最简单的曲线
代码在这里:
注意:Graphics的 drawPath 需要 flash player10
package
{
import flash.display.GraphicsPathCommand;
import flash.display.Sprite;
public class drawCurveLine0 extends Sprite
{
public function drawCurveLine0()
{
super();
graphics.lineStyle(0, 0x000000);
var data:Vector.<Number>=new Vector.<Number>();
data.push(200, 200); graphics.drawCircle(200, 200, 10);//起点
data.push(250, 100); graphics.drawCircle(250, 100,5);//控制点1
data.push(300, 200); graphics.drawCircle(300, 200, 10);//节点2
data.push(400, 250); graphics.drawCircle(400, 250,5);//控制点2
data.push(300, 300);
data.push(250, 400);
data.push(200, 300);
data.push(100, 250);
data.push(200, 200);
var commands:Vector.<int>=new Vector.<int>();
commands.push(GraphicsPathCommand.MOVE_TO);
commands.push(GraphicsPathCommand.CURVE_TO);//样式:曲线
commands.push(GraphicsPathCommand.CURVE_TO);
commands.push(GraphicsPathCommand.CURVE_TO);
commands.push(GraphicsPathCommand.CURVE_TO);
graphics.drawPath(commands, data);//画路径
}
}
}
看明白了么?
就是定义一堆点的数组,再定义一个每两个点之间线型的数组,然后drawPath。
很简单吧,很简洁吧。
另:如果用GraphicsPathCommand.CURVE_TO,
貌似会认为你的节点数组里的点的作用为:
节点1,控制点1,节点2,控制点2,节点3.。。。。。。。。。。。
如果用GraphicsPathCommand.LINE_TO,则是画折现,点数组中点的含义变为:
节点1, 节点2, 节点3. 节点4, 节点5。。。。。。。。。
明天请看用Graphics的 drawPath 来画曲线(2),实现 鼠标拖动节点和控制点的功能。
- 用Graphics的 drawPath 来画曲线(1)
- 用Graphics的 drawPath 来画曲线(2)--可拖动 控制 变形的贝塞尔曲线
- drawPath 画任意多边形
- drawpath
- vs2010 c# graphics 坐标系画曲线
- gdi+中Drawpath()返回值为OutOfMemory的问题
- Android drawPath的简单使用
- canvas.drawPath画特别长线
- 创建双边偏置曲线(通过TOGGLE控件来控制是否保留原来的曲线)
- Core Graphics核心绘图 ( 三) --贝塞尔曲线
- drawPath带波浪纹的圆形
- canvas.drawPath无效,画不出来
- 怎么用U3D画 平滑曲线(贝塞尔曲线)
- 用仿ActionScript的语法来编写html5——第五篇,Graphics绘图
- C#基数样条曲线的模拟实现(对应Graphics的DrawCurve)
- paint()方法中Graphics实例对象是怎么来的
- paint()方法中Graphics实例对象是怎么来的
- paint()方法中Graphics实例对象是怎么来的
- php存入数据库字符处理
- actionscript 字符串 全部替换
- actionscript 读取 文本 配置文件
- Actionscript里的进制及编码转换
- 太逗了 不得不藏 “郭德纲绝句,没有一句不让你笑的”
- 用Graphics的 drawPath 来画曲线(1)
- 用Graphics的 drawPath 来画曲线(2)--可拖动 控制 变形的贝塞尔曲线
- 提升您Flex应用性能 (转)
- 提升您Flex应用性能 --重绘(转)
- Flex中取得Image图像原始大小
- 如何利用FLASH 10的GPU加速功能
- flex (actionscript)用 swf 实现 动态类库(dll)
- 项目导入后flex development css 找不到图片的问题
- 创建一个away3d的flex library 项目