用笛卡尔公式画出的一颗心状图 |
| 作者:未知 来源:网页教学网 更新:2005-6-6 23:45:18 错误报告 我要投稿 |
|
源码:
var Width = Stage.width; var Height = Stage.height; var pen = _root.createEmptyMovieClip("pen_mc", 2); var ib = 0; var End = 90; this.onEnterFrame = function() { if (ib<End) { for (j=0; j<End; j++) { r = Math.PI/45*ib*(1-Math.sin(Math.PI/45*j))*18; x = r*Math.cos(Math.PI/45*j)*Math.sin(Math.PI/45*ib)+Width/2; y = -r*Math.sin(Math.PI/45*j)+Height/4; drawDot(pen, int(x), int(y), 0x00FF00); //drawCircle(pen, int(x), int(y), 2, 0x000000, 0x00FF00, 0); } ib++; } else { delete this.onEnterFrame; } }; /*因为直接for嵌套循环FLASH太吃力了。。所以改用onEnterFrame了... for (i=0; i<90; i++) { for (j=0; j<90; j++) { r = Math.PI/45*i*(1-Math.sin(Math.PI/45*j))*18; x = r*Math.cos(Math.PI/45*j)*Math.sin(Math.PI/45*i)+AppletWidth/2; y = -r*Math.sin(Math.PI/45*j)+AppletHeight/4; drawDot(pen, int(x), int(y), 0x00FF00); //drawCircle(pen, int(x), int(y), 2, 0x000000, 0x00FF00, 0); } } */ function drawDot(pen, x, y, DColor) { pen.moveTo(x-0.5, y); pen.lineStyle(2, DColor, 100); pen.lineTo(x+0.5, y); } |
|
| 文章录入:skyuu 责任编辑:skyuu |
|
| 【字体:小 大】【发表评论】【加入收藏】【告诉好友】【打印此文】【关闭窗口】 |