用户名: 密码: 验证码: QQ--程序群:31736530 动画群:38836599
闪无忧
 
首 页 业界新闻 业界杂谈 Flash教程 Flash源码 Flash图书 Flash酷站 Flex & AIR 供求信息
   本栏目通告:   有意向写收费精品教程的朋友,请联系本站合作
当前位置 :首页>flash教程>Flash as3.0教程>列表

flash as3画线,曲线(Drawing Curved Lines Simplified )

[来源:gskinner.com/blog | 作者:gskinner | 时间:2008-06-03 | 点击:  | 收藏本文  【 】]

I'm bad at drawing curved lines in ActionScript. I'm always too lazy to figure out how to calculate exactly where the control point should go when using curveTo. Because of this, most of my experiments have relied on drawing a lot of short straight line segments to simulate curves, rather than figuring out how to draw the curves properly. For example, my tree experiments are drawn entirely with straight line segments.

While revisiting my grass simulations I decided to bite the bullet and figure out an easy way to work with curves. The result is a couple of "spikes" or isolated test cases that demonstrate the logic behind converting a series of straight lines into a nice looking curve.

The basic concept is to bisect each of the straight lines, then draw a curve between the bisections, using the original points as the curve's control point. Nothing new I'm sure, but it works really well for me, because I can continue to think in straight lines, but draw in curves.

Click to add points. Click and drag points to move them.

 

I also extended this logic to work with fills, which is handy for drawing for drawing things like grass, seaweed, and tentacle monsters (I'm looking at you Peter Organa). To do this, you need to calculate the average angle for each point based on the next and previous points, then draw your curves along points tangential to that angle. If that doesn't make a lot of sense, the example below should clear it up. It's not perfect (still need to deal with the "flip" point that results in crossed lines), but it's been good enough for some of my recent experiments.

 

You can download the test files here.

文章如果有错误或者缺少文件,请发邮件提交给我们
上一篇:由ActionScript3入Silverlight之集合篇
下一篇:as3中一些不太常见的代码写法
Tags:    
>>> 最新评论:(共有 0 位网友发表了评论)      查看所有评论
  发表评论
用户名: 新注册) 密码: 匿名评论
评论内容:(不能超过250字,需审核后才会公布,请自觉遵守互联网相关政策法规。
·本站发布内容均为客观表达作者观点,不代表闪无忧立场,请勿攻击和漫骂
·用户发表意见仅代表其个人意见,并且承担一切因发表内容引起的纠纷和责任
·本站管理人员有权在不通知用户的情况下删除不符合规定的评论信息或留做证据
·请客观的评价您所看到的资讯,提倡就事论事,杜绝漫骂和人身攻击等不文明行为
  教程分类
  基础操作   动画特效
  应用开发   组件学习
  As程序   动画教程
  Flash cs3   AS 3.0
  FCS/FMS教程   Loading教程
  Flash与Web   Flash教程连载
  相关文章
·ActionScript 3.0垃圾回收
·Flash上传客户端
·AS3编码转换函数
·flash as3的binding-ObjectProxy
·as3的ComboBox组件应用小问题
·小球的弹性碰撞
·小球的弹性碰撞
·小球的弹性碰撞
·ActionScript 3设计模式类图(二)
·ActionScript 3设计模式类图(一)
  热门文章
·Flash进度条的制作详细讲解(组图)
·flash幻灯片网页效果
·Flash打造简单的飘雪动画视觉特效
·Flash旋转拖尾文字效果的制作教程
·flash水影效果字
·全Flash动画网站实现的基础教学
·超酷flash光晕移动效果
·flash春雷闪电效果
·Flex 3 AdvancedDataGrid的使用(第二
·Flash制作大雪纷飞效果动画
·即拷即用的loading代码
关于我们 - 免责声明 - 网站地图 - 商务服务 - 联系我们 - RSS地图
©CopyRight 2006-2008, 5UFlash.COM, Inc. All Rights Reserved
鲁ICP备06034971号