Dilation of line or object

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:

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?

i understand you want variation of line length while rotating:

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;
}
1 Like

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.


I believe dilation help a lot to create any shape like that. thanks for your answer its already useful.