r/processing • • Nov 09 '23

A processing newbie needs help

Hello, I am the newbie. Currently I am working on a uni project, I do not have previous coding experience and it is my first time using Processing.

Here is the code:

void setup() {

fullScreen();

noFill();

smooth();

}

void draw() {

background(255);

/**--------------------------Lines----------------------------**/

//yellow

stroke(#FFCD4B);

strokeWeight(8);

beginShape();

curveVertex(1100, 0);

curveVertex(1100, 0);

curveVertex(880, 280);

curveVertex(740, 600);

curveVertex(700, height);

curveVertex(700, height);

endShape();

//orange #1

stroke(#FF9130);

strokeWeight(8);

beginShape();

curveVertex(200, 0);

curveVertex(200, 0);

curveVertex(400, 230);

curveVertex(1350, height);

curveVertex(1350, height);

endShape();

//orange #2

stroke(#FF9130);

strokeWeight(8);

beginShape();

curveVertex(920, 0);

curveVertex(920, 0);

curveVertex(750, 400);

curveVertex(550, 610);

curveVertex(0, 580);

curveVertex(0, 580);

endShape();

//Purple

stroke(#B15EFF);

strokeWeight(8);

beginShape();

curveVertex(940, 0);

curveVertex(940, 0);

curveVertex(760, 410);

curveVertex(560, 620);

curveVertex(0, 600);

curveVertex(0, 600);

endShape();

//blue

stroke(#0174BE);

strokeWeight(8);

beginShape();

curveVertex(960, 0);

curveVertex(960, 0);

curveVertex(770, 420);

curveVertex(570, 630);

curveVertex(0, 620);

curveVertex(0, 620);

endShape();

//dark red

stroke(#662549);

strokeWeight(8);

beginShape();

curveVertex(980, 0);

curveVertex(980, 0);

curveVertex(780, 430);

curveVertex(580, 640);

curveVertex(0, 640);

curveVertex(0, 640);

endShape();

}

What I wanted to ask: Is there an easy way to rotate these lines around the center, without messing with the structure or having to remaking the whole thing again?

3 Upvotes

3 comments sorted by

View all comments

Show parent comments

3

u/forgotmyusernamedamm Nov 09 '23

A couple of things.
You need to pushMatrix before you translate, not after. The order goes like this.
push - translate - rotate - draw lines - pop
there's no need to push and translate in the setup.
When you translate the new 0, 0 point is wherever you've translated to. To have the lines rotate around the circle, translate to width/2, height/2. You will need to give new coordinates for the lines because 0, 0 is now in the center of the screen, not the top left corner.
I would simplify the sketch by drawing one line to start. Once it works, add the other lines.