# Smooth curves...no not a female?

**URL:** <https://forum.kirupa.com/t/smooth-curves-no-not-a-female/29976>\
**Category:** Uncategorized\
**Created:** [September 2, 2003, 3:37pm UTC](https://forum.kirupa.com/t/smooth-curves-no-not-a-female/29976 "2003-09-02T15:37:15Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![7of9](https://avatars.discourse-cdn.com/v4/letter/7/c89c15/32.png) [@7of9](https://forum.kirupa.com/u/7of9)\
**Post date:** [September 2, 2003, 3:37pm UTC](https://forum.kirupa.com/t/smooth-curves-no-not-a-female/29976/1 "2003-09-02T15:37:15Z")

</div>

Using the lineto property, how can I create a simple rectanglar box with smooth round curves at the edges? Small piece of code will be nice.

thanks

---

<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:** [September 2, 2003, 4:06pm UTC](https://forum.kirupa.com/t/smooth-curves-no-not-a-female/29976/2 "2003-09-02T16:06:37Z")

</div>

hmm use Math.cos and maybe Math.sin

Found this @ [actionscript.org](http://actionscript.org)

```auto

speed = 5;
r = 200;
xc = 150;
yc = 150;
angle = 0;
delta = Math.PI/180;
	createEmptyMovieClip("circle", 1);
	with (circle) {
		lineStyle(0, 0x666666, 50);
		moveTo(r+xc*Math.cos(angle*delta),r+xc*Math.sin(angle*delta))
	}
onEnterFrame = function () {
	x = r+xc*Math.cos(angle*delta);
	y = r+yc*Math.sin(angle*delta);
	angle += speed;
	if (angle>359) {
		angle -= 360;
	}
	circle.lineTo(x, y);
};

```

Maybe you can use it.

---

<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:** [September 2, 2003, 5:04pm UTC](https://forum.kirupa.com/t/smooth-curves-no-not-a-female/29976/3 "2003-09-02T17:04:29Z")

</div>

[http://proto.layer51.com/d.aspx?f=635](http://proto.layer51.com/d.aspx?f=635)

---

<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:** [September 2, 2003, 8:39pm UTC](https://forum.kirupa.com/t/smooth-curves-no-not-a-female/29976/4 "2003-09-02T20:39:54Z")

</div>

That proto looks very nice 🙂 Here’s my try at it, shorter, but much more approximative:

```auto
//w : width, h: height, r: radius of the edge, col: color of the fill
MovieClip.prototype.roundedBox = function (w, h, r, col) {
	var aPoints = [{x:r, y:0},{x:w-r, y:0},{x:w, y:r},{x:w, y:h-r},{x:w-r, y:h},
				   {x:r, y:h},{x:0, y:h-r},{x:0, y:r}] ;
	this.lineStyle(2*r, col, 100) ;
	this.moveTo(r, r) ;
	this.lineTo(r+.45, r+.15) ;
	this.moveTo(r, h-r) ;
	this.lineTo(r+.45, h-r+.15) ;
	this.moveTo(w-r, h-r) ;
	this.lineTo(w-r+.45, h-r+.15) ;
	this.moveTo(w-r, r) ;
	this.lineTo(w-r+.45, r+.15) ;
	this.lineStyle(0, 0, 0) ;
	this.beginFill(col, 100) ;
	for (var i=0; i < aPoints.length; i++) this[(!i) ? "moveTo" : "lineTo"](aPoints*.x, aPoints*.y) ;	
	this.endFill() ;
}
this.createEmptyMovieClip("box", 0) ;
box.roundedBox(300, 400, 30, 0xff0000) ;

```

pom 🙂
