i'm a begginer, need help please
in
Programming Questions
•
1 year ago
hi, i found a code in sktechpad and i manipulated it a little bit.
i want 3 different shapes in 3 different possessions. but it gives me only one.
- float currentx;
float currenty;
void setup() {
size(400, 400);
smooth();
noStroke();
currentx = width / 2;
currenty = height / 2;
}
void draw(){
background(#C95F45);
drw(200,30,50);
drw(10,80,10);
drw(350,70,50);
}
void drw(float pos,int seg,int shape_size){
int Segments = seg;
float x[] = new float[Segments];
float y[] = new float[Segments];
currentx = lerp(currentx, pos, 0.05);
currenty = lerp(currenty, pos, 0.05);
for (int i=0; i<Segments; i++) {
float angle = float(i) / float(Segments) * TWO_PI;
float distance = shape_size + 10 * noise(i, frameCount/50.0);
x[i] = currentx + sin(angle) * distance;
y[i] = currenty + cos(angle) * distance;
}
beginShape();
fill(#D3E2E5);
for (int i=0; i<Segments+4; i++) {
curveVertex(x[i % Segments], y[i % Segments]);
}
endShape();
}
1