# Drawing api

**URL:** <https://forum.kirupa.com/t/drawing-api/258294>\
**Category:** Uncategorized\
**Created:** [April 22, 2008, 7:49pm UTC](https://forum.kirupa.com/t/drawing-api/258294 "2008-04-22T19:49:46Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![wilmelk](https://avatars.discourse-cdn.com/v4/letter/w/b5ac83/32.png) [@wilmelk](https://forum.kirupa.com/u/wilmelk)\
**Post date:** [April 22, 2008, 7:49pm UTC](https://forum.kirupa.com/t/drawing-api/258294/1 "2008-04-22T19:49:46Z")

</div>

Hi there.

I have this problem with the drawing api and especially with curveTo function. i have these 8 or even more points. Doesn’t really matter, and i want to connect them all with curved lines.  
[40,0],[460,0],[500,40],[500,340],[460,380],[40,380],[0,340],[0,40]

Initially it will look like a rounded rectangle. I know about the drawRounded blah blah blah built in function but i need to do it this way. I want to animate each point’s x,y randomly and redraw the curves on tween updates. but i can’t do the curves properly.

This is what i get. I have tried everything, and i just can’t get the curve closed.

![](http://www.rastavibe.gr/discurved.jpg)

This is my function

function updateCurves():void {

```
 var lineDrawing:MovieClip = new MovieClip();     
 var thisPoint:MovieClip = new MovieClip();
 var nextPoint:MovieClip = new MovieClip();
 
 this.addChild(lineDrawing);
 lineDrawing.graphics.clear();
        
 var startX:int = points[0].x;
 var startY:int = points[0].y;
 var endX:int, endY:int;
 lineDrawing.graphics.lineStyle(1, 0x000000, 1 );
 lineDrawing.graphics.beginFill( 0x990000, 1 );
 lineDrawing.graphics.moveTo(startX,startY);
        
 for (var h:int = 0; h&lt;points.length; h++) {
      thisPoint = points[h];
      nextPoint = points[h+1];
      endX = (thisPoint.x+nextPoint.x)/2;
      endY = (thisPoint.y+nextPoint.y)/2;
      lineDrawing.graphics.curveTo(thisPoint.x,thisPoint.y,endX,endY);
      }

```

}

Please give feedback on my function…

Many thanks in advance
