How to draw a triangle in a math graph?

前端 未结 2 523
长情又很酷
长情又很酷 2021-01-22 03:39

How to draw a triangle in a math graph which displays X and Y axis.

2条回答
  •  情书的邮戳
    2021-01-22 03:57

    It sounds like you need to know how the drawing API works in Flash. Your question is kind of vague, but this might help to get you started - google "Flash Drawing API" for more information.

    var point1:Point = new Point (0, 0);
    var point2:Point = new Point (25, -50);
    var point3:Point = new Point (50, 0);
    
    var s:Sprite = new Sprite();
    s.graphics.lineStyle(1, 0xff0000);
    s.graphics.beginFill(0x000000);
    
    s.graphics.moveTo(point1.x, point1.y);
    s.graphics.lineTo(point2.x, point2.y);
    s.graphics.lineTo(point3.x, point3.y);
    s.graphics.lineTo(point1.x, point1.y);
    
    s.graphics.endFill();
    s.graphics.lineStyle(0);
    
    s.x = (stage.stageWidth - s.width) / 2;
    s.y = ((stage.stageHeight - s.height) / 2) + 50;
    
    addChild(s);
    

    I hope that helps, let me know if you have any questions.

    NOTE: This solution is using ActionScript 3. If you need AS2 this won't work, and off the top of my head I don't know how to help but you might just try googling "AS2 Drawing API" or something to that effect.

提交回复
热议问题