# Drawing API (angle formula)

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.

â€“Elios

``````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]``````

Thanks alot.

Later,
â€“Elios