We are about to switch to a new forum software. Until then we have removed the registration on this forum.
I am new to coding and I'm hopping to create a program that creates a twining vine. My code so far is not the best but I am looking for feedback. I want he base of the vine to be thick while the top is thin. it would be cool to add leaves but I'm not sure how to go about doing that.
int nbr_circles = 300; //Number of circles more circles faster growth
void setup() {
size(600, 600);
smooth();
frameRate(10);
}
void draw() {
background(255);
noStroke();
float elapsedSeconds = millis()*.001;
float angle_incr = radians(frameCount/30.0); //angle increment radians in realtion to fram count
float cx = width/2; //location of x starting point
float cy = height; //location of y starting point
float outer_rad = width*.2; //radius of the spiral
float sm_diameter = 4; //diameter of vine stem
float ratio;
float spiral_rad;
float theta = 0;
float x, y;
for (int i = 3; i <= nbr_circles; ++i) {
ratio = i/(float)nbr_circles; //the ration is i/number of circles, determines intesityof angle
spiral_rad= ratio/2 * outer_rad/2; //Sprial radius is ratio * outer radius
theta = i * angle_incr;
x = cx + cos(theta) * spiral_rad/2;
y = cy + sin(theta) * spiral_rad/2;
theta += .1;
fill(50, 205, 50);
ellipse(x-i, y-i, sm_diameter, sm_diameter);
}
for (int j = 3; j <= nbr_circles; ++j) {
ratio = j/(float)nbr_circles; //the ration is i/number of circles, determines intesityof angle
spiral_rad= ratio/2 * outer_rad/2; //Sprial radius is ratio * outer radius
theta = j * angle_incr;
x = cx - cos(theta) * spiral_rad/2;
y = cy - sin(theta) * spiral_rad/2;
theta += .1;
fill(100, 255, 100);
ellipse(x-j, y-j, sm_diameter, sm_diameter);
}
}
Answers
i found this code and would like to not have the camera angles but I'm not sure how to do so... also I would like to simplify this code a lot so its more understandable. I would like the lines to start in the lower left and end in upper right
Please learn how to format your code for posting on this forum... Highlight it and hit Ctrl-K or the C button above the text entry box.