# Dilation of line or object

**URL:** https://discourse.processing.org/t/dilation-of-line-or-object/2520
**Category:** Coding Questions
**Created:** [August 9, 2018, 11:38pm UTC](https://discourse.processing.org/t/dilation-of-line-or-object/2520 "2018-08-09T23:38:27Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![rebin](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/rebin/32/994_2.png) [@rebin](https://discourse.processing.org/u/rebin)
#### Post date: [August 9, 2018, 11:38pm UTC](https://discourse.processing.org/t/dilation-of-line-or-object/2520/1 "2018-08-09T23:38:27Z")

</div>

Let say we have a line or a shape I need to dilate that shape. Do we have any way to do this in processing?

for example, I have this code:

```auto
void setup(){
  size(500,500);
  background(20);
}
float theta=0;

void draw(){
  stroke(255,0,0);
  pushMatrix();
  translate(width/2,height/2);
  rotate(theta);
  line(-100,-100,100,100);
  popMatrix();
theta=theta+0.1;
}

```

and when I rotate it create circle. but I need to dilate the line while rotate, so for example I want to control length of the line based of the angle of rotation.

another way, can we dilate this line that eventually create a square? or a star?

---

<div class="post-metadata">

### Author: ![kll](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/kll/32/964_2.png) [@kll](https://discourse.processing.org/u/kll)
#### Post date: [August 10, 2018, 3:29am UTC](https://discourse.processing.org/t/dilation-of-line-or-object/2520/2 "2018-08-10T03:29:24Z")

</div>

i understand you want variation of line length while rotating:

 ![](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/c/c05accd4317f6603aed2aff824f691961266fcea.jpeg)

```auto
void setup(){
  size(500,500);
  background(20);
}
float theta=0;
float amp=15.0, swings=5.0, longhalf = 100.0, thisline=0.0;

void draw(){
  stroke(255,0,0);
  pushMatrix();
  translate(width/2,height/2);
  rotate(theta);
  thisline=longhalf+amp*sin(theta*swings);
  line(-thisline,-thisline,thisline,thisline);
  popMatrix();

  theta=theta+0.1;
}

```

---

<div class="post-metadata">

### Author: ![rebin](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/rebin/32/994_2.png) [@rebin](https://discourse.processing.org/u/rebin)
#### Post date: [August 10, 2018, 5:11am UTC](https://discourse.processing.org/t/dilation-of-line-or-object/2520/3 "2018-08-10T05:11:39Z")

</div>

> [@kll](#):
>
> void setup(){ size(500,500); background(20); } float theta=0; float amp=15.0, swings=5.0, longhalf = 100.0, thisline=0.0; void draw(){ stroke(255,0,0); pushMatrix(); translate(width/2,height/2); rotate(theta); thisline=longhalf+amp_sin(theta_swings); ; line(-thisline,-thisline,thisline,thisline); popMatrix(); theta=theta+0.1; }

Thanks. your reply is very helpful. but one question. Because of trig function the shape created is round. is possible to rotate a line to create shape that is not round… for example when you rotate a line you get square, or shape like in the pic.

 ![51](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/b/bd7812d5a849dbaa7db92cd9d9f1ec9d887c8421.png)  
I believe dilation help a lot to create any shape like that. thanks for your answer its already useful.
