- 浏览: 182573 次
- 性别:
- 来自: 哈尔滨
文章分类
最新评论
-
tongzelong:
[b][i][flash=200,200][url][img] ...
Postgresql中的分组函数(group by 和 having) -
csniper:
console.assert(foo_show()=='win ...
js bind 函数 使用闭包保存执行上下文
转自:http://sjkgxf7191.iteye.com/blog/520184
Flash Player 10 使用绘图API
POSTED BY CHENCHAO | FILED UNDER 3D相关
了解 Graphics 类
- 每个 Shape 、Sprite 和 MovieClip 对象都具有一个 graphics 属性,它是 Graphics 类的一个实例。
- 如果要将显示对象仅用作内容 绘制画布,则可以使用 Shape 实例。
- Shape 实例的性能优于其它 用于绘制的显示对象,因为它不会产生 Sprite 和 MovieClip 类中的附加功能的开销。
- 如果希望能够在显示对象上绘制图形内容,并且还希望该对象包含其它显示对象 ,则可以使用 Sprite实例。
矢量
- 数据类型完全相同 的值组成的数组。
- Vector 对象可存储绘制方法 使用单个命令构建线条和形状时所用值 的数组。
使用图形数据类
可以将全部绘制存储 在 IGraphicsData 类型的矢量对象数组 (Vector.<IGraphicsData> ) 中,该数组可以重复
用作其它形状实例的数据源,也可以存储绘制信息供以后使用。
GraphicsStroke
GraphicsSolidFill
GraphicsGradientFill
GraphicsShaderFill
GraphicsEndFill
GraphicsPath
GraphicsTrianglePath
路径
drawPath(commands:Vector.<int>, data:Vector.<number>) |
第一个参数保存命令 ,第二个参数保存数据
第一个参数命令如下:
flash.display.GraphicsPathCommand 类里
public static const NO_OP:int = 0;
public static const MOVE_TO:int = 1;
public static const LINE_TO:int = 2;
public static const CURVE_TO:int = 3;
public static const WIDE_MOVE_TO:int = 4;
public static const WIDE_LINE_TO:int = 5;
画直线 参考代码如下:
var commands:Vector.<int> = new Vector.<int>(); commands[0] = GraphicsPathCommand.MOVE_TO; commands[1] = GraphicsPathCommand.LINE_TO; var data:Vector.<Number> = new Vector.<Number>(); data[0] = 100; data[1] = 100; data[2] = 250; data[3] = 200; graphics.lineStyle(0); graphics.drawPath(commands, data); |
画曲线 参考代码如下:
commands.push(GraphicsPathCommand.MOVE_TO); // 起点是200, 200 data.push(200, 200); data.push(250, 100); data.push(300, 200); data.push(400, 250); data.push(300, 300); data.push(250, 400); data.push(200, 300); data.push(100, 250); data.push(200, 200); commands.push(GraphicsPathCommand.CURVE_TO); commands.push(GraphicsPathCommand.CURVE_TO); commands.push(GraphicsPathCommand.CURVE_TO); commands.push(GraphicsPathCommand.CURVE_TO); |
WIDE_LINT_TO模式 参考代码如下:
data.push(200, 200); data.push(250, 100); data.push(300, 200); data.push(400, 250); data.push(300, 300); data.push(250, 400); data.push(200, 300); data.push(100, 250); data.push(200, 200); lineCommands.push(GraphicsPathCommand.MOVE_TO); // 使用WIDE_LINE_TO命令可以跳过data中的前一组坐标,跟CURVE_TO同步 lineCommands.push(GraphicsPathCommand.WIDE_LINE_TO); lineCommands.push(GraphicsPathCommand.WIDE_LINE_TO); lineCommands.push(GraphicsPathCommand.WIDE_LINE_TO); lineCommands.push(GraphicsPathCommand.WIDE_LINE_TO); |
缠绕
顺时针 :正向 缠绕;逆时针 :负向 缠绕
在一次beginFill/endFill 时,出现路径交叉 ,那么默认是不填充 交叉部分的
GraphicsPathWinding.EVEN_ODD :默认情况
graphics.drawPath(commands, data1, GraphicsPathWinding.EVEN_ODD); |
GraphicsPathWinding.NON_ZERO :
如果两个路径的缠绕一致 (都或正或者负),则填充 交叉区域。
如果两个路径的缠绕不一致 (一正一负),则不填充 交叉区域。
graphics.drawPath(commands, data1, GraphicsPathWinding.NON_ZERO); |
三角形
一个 drawTriangles参数
var vertices:Vector.<Number> = new Vector.<Number>(); vertices.push(100, 100); vertices.push(200, 100); vertices.push(150, 200); graphics.lineStyle(0); graphics.drawTriangles(vertices); |
两个 drawTriangles参数,可以减少顶点的总数目
var vertices:Vector.<Number> = new Vector.<Number>(); vertices.push(100, 100); vertices.push(200, 100); vertices.push(200, 200); vertices.push(100, 200); var indices:Vector.<int> = new Vector.<int>(); indices.push(0, 1, 2); indices.push(2, 3, 0); graphics.lineStyle(0); graphics.drawTriangles(vertices, indices); |
uvtData
drawTriangles的第三个可选参数 还是一个Vector (Number型),称作uvtData 。uvt表示了影响位图映射于三角形的三个值。u和v 代表x轴和y轴 的比例,t 在用于3D时代表缩放 。
var vertices:Vector.<Number> = new Vector.<Number>(); vertices.push(150, 50); vertices.push(1000, 100); vertices.push(800, 600); vertices.push(100, 200); var uvtData:Vector.<Number> = new Vector.<Number>(); uvtData.push(0, 0); uvtData.push(1, 0); uvtData.push(1, 1); uvtData.push(0, 1); var indices:Vector.<int> = new Vector.<int>(); indices.push(0, 1, 2); indices.push(2, 3, 0); var bitmap:Bitmap = new ImageClass() as Bitmap; graphics.beginBitmapFill(bitmap.bitmapData); graphics.drawTriangles(vertices, indices, uvtData); graphics.endFill(); |
三角形和3D
使用三角实现3D的基本策略 :
1. 创建一堆三角结构顶点和索引 。
2. 计算于每个顶点相符的3D坐标点位置 。
3. 使用透视法 计算3D坐标点在屏幕上的坐标 ,作为定点的值。
perspectiveScale = focalLength / (focalLength + zPosition) |
一个含有x,y,z的坐标点,z坐标用于求出缩放比例。然后用这个比例乘以x,y就能得到点在屏幕上的位置,这个位置也就是顶点的值。可以将这个值作为uvtData 的第三个参数 。
var scale:Number = focalLength / (focalLength + zpos + centerZ); vertices.push(xpos * scale, ypos * scale); uvtData.push(j / (cols - 1), i / (rows - 1)); uvtData.push(scale); |
4. 使用drawTriangles 传入顶点和索引。
culling
drawTriangles的第四个可选参数culling,它是一个字符串,接收"positive","negative","none"三个值。
TriangleCulling.POSITIVE :剔除逆时针 的三角形
TriangleCulling.NEGATIVE :剔除顺时针 的三角形
TriangleCulling.NONE:全部绘制
sprite.graphics.drawTriangles(vertices, indices, uvtData, TriangleCulling.NEGATIVE); |
发表评论
-
Flex与 JS 交互通信方法
2012-05-20 11:35 820http://www.gnria.com/flex/flex- ... -
Flex中阻止默认事件的派发
2011-11-23 10:37 1889<?xml version="1.0&q ... -
Flex3的国际化支持
2011-11-10 19:25 1020Flex的国际化支持 Author:lvmy Ema ... -
《Flash ActionScript 3.0 动画教程》自学笔记
2011-06-14 10:29 1084第 1 章:基本动画概念 略 第 ... -
Flex 元标签列表
2011-05-09 15:12 898转载:http://phpz.org/archiv ... -
Flex 4.5 SDK 新特性
2011-05-04 10:12 1645转载:http://www.adobe.com/cn/de ... -
Flex使用swfloader引入swf后导致页面失真
2011-04-11 09:58 1826最近在项目中需要引入一个由gif转换过来的swf动画文件,引入 ... -
AS3自学笔记,慢慢补充
2011-03-21 17:34 11721、as原型机制使用 prototype 为原型类添加修改成员 ... -
flash 开源项目
2011-03-15 11:33 905flash 开源项目 转载 ... -
flex 开源项目组件大全
2011-03-15 11:32 1786flex 开源项目组件大全 转载自:http: ... -
[转]推荐几个Adobe Flex Builder 3的插件(代码格式化和fms服务器通讯文件(main.asc)编写)
2011-01-14 10:50 914本人转载自:http://www.cnblogs.com/ai ... -
[转载]我对IList、ICollectionView与IViewCursor的一点理解
2011-01-12 09:57 1486若需转载本站原创文章,请注明: 转载自zrong's Blog ... -
Flex 获取本地文件的路径
2010-10-25 17:10 32501、Flex代码部分: <?xml version= ... -
[转载]Flex自定义Alert窗口显示位置
2010-10-25 16:06 1018原创作者: Abdul Qabiz 。翻译整理:一路风尘 ...
相关推荐
\flashplayer10\flashplayer10
flashplayer_10_ax_debugflashplayer_10_ax_debugflashplayer_10_ax_debugflashplayer_10_ax_debugflashplayer_10_ax_debug
Flash Player离线安装包下载
最新flashplayer离线安装包下载
FlashPlayer11-5安装包FlashPlayer11-5安装包FlashPlayer11-5安装包FlashPlayer11-5安装包
Adobe Flash Player(Flash Player官方下载)是一个集成的多媒体播放器,让你在Web上享受更广泛的多媒体体验。Adobe Flash Player官方版可显示和播放多媒体内容,从数以千计的高度交互性的flash player下载,到有音频...
FlashPlayer10 支持flash播放,很好用,很方便,谢谢下载!
install_flash_player_10_active_xvinstall_flash_player_10_active_xinstall_flash_player_10_active_xinstall_flash_player_10_active_xinstall_flash_player_10_active_xinstall_flash_player_10_active_xinstall...
flashplayer_10_sa SWF动画播放工具 本地播放
flashplayer_10_ax_debug flashplayer_10_sa flashplayer_10_sa_debug
flashplayer11_b1_install_win_ie32_071311flashplayer11_b1_install_win_ie32_071311flashplayer11_b1_install_win_ie32_071311flashplayer11_b1_install_win_ie32_071311flashplayer11_b1_install_win_ie32_071311...
很多的朋友反映,将喜欢的Flash动画下载到自己的电脑后总是用IE浏览器或者第三方Flash播放器才能观看,感觉不好,希望用Macromedia的Flash Player播放,可是又很难找到!现在我就发一个最新版本的给大家!不过请注意...
FlashPlayer created with delphi 7
flashplayer V10.1.85,单文件运行
flashplayer_10.exe 不错的播放工具
众所周知 adobe flash player 已被苏-州-思-杰-马-克-丁-代-理 在flash临死前打捞一笔 目前最新版本31 会弹出 ff资讯弹窗 Flash Helper Service服务后台常驻 收集用户隐私 如果禁止 flash将不可用 现在我收集了...
flashplayer10_1_p3_activex_022310.exe
install_flash_player_10