zoukankan      html  css  js  c++  java
  • 数学类 绘制线条

                                                                    绘画函曲线线条练习

    import flash.display.Shape;

    import flash.events.Event;

    var sp:Shape = new Shape();

    var sp1:Shape = new Shape();

    var v:Number = 0; // 开始速度

    var hd:Number = 0; //弧度

    sp.graphics.lineStyle(2,0x00ff00);

    sp1.graphics.lineStyle(2,0x000fff);

    sp.graphics.moveTo(50,50);

    sp.graphics.lineTo(50,350);

    sp.graphics.moveTo(50,200);

    sp.graphics.lineTo(500,200);

    sp.graphics.moveTo(50,200);

    sp1.graphics.moveTo(50,200);

    stage.addChild(sp);

    stage.addChild(sp1);

    this.addEventListener(Event.ENTER_FRAME,OnHandler);

    function OnHandler(e:Event):void

    {  

    v += 2;

     hd += 0.1;

     sp.graphics.lineTo(50 + v,200 - Math.sin(hd) * 100);

     sp1.graphics.lineTo(50 + v,Math.sin(hd) * 100 + 200);

    }

                                                   数学类、绘图练习

    import flash.events.Event;

    import flash.display.*;

    import flash.events.MouseEvent;

     //———————————————— 旋转的小球 ————————————————

    var arr:Array = [mc1,mc2,mc3,mc4];

    var r:int = 120;

    var hd:Number = 0;

    this.addEventListener(Event.ENTER_FRAME,OnHandler);

    function OnHandler(e:Event):void

    {

     hd += 0.1;

     for(var i:int = 0; i < arr.length; i++)

     {   

    arr[i].x = Math.cos(Math.PI * 2/4 * i + hd)* r + 275;

      arr[i].y = Math.sin(Math.PI * 2/4 * i + hd)* r + 200;

     }

    }

    //——————————————— 绘画带有边框的圆 ———————————————

    var sp:Shape = new Shape();

    sp.graphics.lineStyle(2,0x000fff);

    sp.graphics.beginFill(0x00ff00,0.2);

    sp.graphics.drawCircle(100,200,100);

    stage.addChild(sp);

    //———————————————— 绘画曲线 ———————————————————

    var x1:Number = 0;

    var y1:Number = 0;

    var cx1:Number = 275;

    var cy1:Number = 400;

    var x2:Number = 550;

    var y2:Number = 0;

    sp.graphics.moveTo(x1,y1);

    var c:Number = cx1 * 2 - (x1 + x2)/2;

    var c1:Number = cy1 * 2 - (y1 + y2)/2;

    sp.graphics.curveTo(c,c1,x2,y2);

    stage.addChild(sp);

    sp.graphics.clear(); //清除绘画的图形

  • 相关阅读:
    Shell变量之自定义变量、环境变量
    Shell变量命名规则
    获取文件编码格式
    基于Lucene的文件检索Demo
    数据库压力测试工具
    插入ts以及判断列是否存在(支持多数据库)
    (摘)Chart属性设置
    (摘)C#comboBox绑定数据
    (摘)ORACLE DBA的职责
    (摘)DataGuard物理standby管理
  • 原文地址:https://www.cnblogs.com/klh5211314/p/2763386.html
Copyright © 2011-2022 走看看