# Drawing API (angle formula)

**URL:** <https://forum.kirupa.com/t/drawing-api-angle-formula/21843>\
**Category:** flash\
**Created:** [May 27, 2003, 6:46am UTC](https://forum.kirupa.com/t/drawing-api-angle-formula/21843 "2003-05-27T06:46:32Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Elios](https://avatars.discourse-cdn.com/v4/letter/e/2acd7d/32.png) [@Elios](https://forum.kirupa.com/u/Elios)\
**Post date:** [May 27, 2003, 6:46am UTC](https://forum.kirupa.com/t/drawing-api-angle-formula/21843/1 "2003-05-27T06:46:32Z")

</div>

👽

Alright, I suddenly have a lot of time on my hands, so I decided to start learning how to use the drawing API. I went through the simple tut on it here. That’s easy, I understand how it all works (dealt with moveTo and lineTo). Okay, but my question now is this: “What is the simplest mathematical formula for moving a line (or rather calculating a line to…) along an angle.” I’ve attached my source, albeit messy as I didn’t think I’d have a problem, and you can see I just made up some junk to get it to go -like- an angle. Anyway, the function which has all the vital stuff in it is on the first frame…shouldn’t be hard to find.

Anyway, thanks in advance,  
–Elios

👽

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [May 27, 2003, 9:53am UTC](https://forum.kirupa.com/t/drawing-api-angle-formula/21843/2 "2003-05-27T09:53:29Z")

</div>

```auto
angle = 40 ;
dtr = Math.PI / 180 ; // degrees to radians
long = 20 ;
startx = 50 ;
starty = 50 ;

this.lineStyle(0);
this.moveTo(startx,starty);

endx = startx + long * Math.cos (angle * dtr);
endy = starty + long * Math.sin (angle * dtr);

this.lineTo(endx,endy);[/As]
```

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [May 27, 2003, 6:07pm UTC](https://forum.kirupa.com/t/drawing-api-angle-formula/21843/3 "2003-05-27T18:07:40Z")

</div>

Thanks alot.

Later,  
–Elios
