Hi all.
I am working on this sketch where I am trying to simulate the inner circles of the tree trunk with a proximity sensor connected to Arduino whose values determine the width of these circles.
I wanted to ask if there is a way to make some points of the shape change as it increases on the X-axis.
So that it is not just a simple "scale* as in the code example below but that there is a parameter that progressively alters the shape the more you go toward the horizontal direction.
Thank you for your response!
import processing.serial.*;
int lf = 10; // Linefeed in ASCII
String myString = null;
Serial myPort; // The serial port
int startTime;
void setup(){
size(1000,1000);
background(0);
stroke(255, 10);
noFill();
noLoop();
startTime = millis();
myPort = new Serial(this, "COM4", 9600);
myString = myPort.readStringUntil(lf);
myString = null;
}
void draw(){
while (myPort.available() > 0)
{
myString = myPort.readStringUntil(lf);
if (myString != null)
{
println(myString);
float centerX = 0;
float centerY = 0;
for (int i = 1; i <= 10; i++) {
pushMatrix();
scale(float(myString)/20);
beginShape();
curveVertex(centerX, centerY);
curveVertex(centerX, centerY - 50);
curveVertex(centerX - 30, centerY - 50);
curveVertex(centerX - 50, centerY);
curveVertex(centerX - 50, centerY + 50);
curveVertex(centerX, centerY + 50);
curveVertex(centerX + 50, centerY + 50);
curveVertex(centerX + 50, centerY);
curveVertex(centerX + 25, centerY - 25);
curveVertex(centerX, centerY);
endShape(CLOSE);
popMatrix();
}
if (millis() - startTime > 30000) {
background(0);
startTime = millis();
}
}
}
}
void keyPressed() {
loop();
}