How do I make multiple trees for this Processing code?

How do I make multiple trees for this Processing code?

I have been playing around with a processing code of a tree that branches out and I would like to arrange multiple on the screen. I am new to processing and have tried to do it myself with no luck.
Please let me know if you can help!

Thanks, Melissa

Here is the code:



float theta; void setup() { size(640, 360); smooth(); } void draw() { background(0); frameRate(30); stroke(255); // Let's pick an angle 0 to 90 degrees based on the mouse position float a = (mouseX / (float) width) * 90f; // Convert it to radians theta = radians(a); // Start the tree from the bottom of the screen translate(width/2,height); // Draw a line 120 pixels line(0,0,0,-120); // Move to the end of that line translate(0,-120); // Start the recursive branching! branch(120); } void branch(float h) { // Each branch will be 2/3rds the size of the previous one h *= 0.66; // All recursive functions must have an exit condition!!!! // Here, ours is when the length of the branch is 2 pixels or less if (h > 2) { pushMatrix(); // Save the current state of transformation (i.e. where are we now) rotate(theta); // Rotate by theta line(0, 0, 0, -h); // Draw the branch translate(0, -h); // Move to the end of the branch branch(h); // Ok, now call myself to draw two new branches!! popMatrix(); // Whenever we get back here, we "pop" in order to restore the previous matrix state // Repeat the same thing, only branch off to the "left" this time! pushMatrix(); rotate(-theta); line(0, 0, 0, -h); translate(0, -h); branch(h); popMatrix(); } }

      • Sticky Posts

      • My Zoho Story #19 - How and IT service provider, CTSP, are streamlining customer support using Zoho

        My Zoho Story is a video podcast series where we connect with Zoho users worldwide to hear from them about their experiences with Zoho and how it became an integral part of their everyday business life. Our recent 'My Zoho Story' took us to Australia
      • My Zoho Story #18- How Mirage Visual Limited achieved enhanced customer service experience, using Zoho

        My Zoho Story is a video podcast series where we connect with Zoho users worldwide to hear from them about their experiences with Zoho and how it became an integral part of their everyday business life. Our recent interview with Sam Blenkiron from Mirage
      • My Zoho Story #17 - How Superior Trucking Payroll Service scaled their business with Zoho

        My Zoho Story is a video podcast series where we connect with Zoho users worldwide to hear from them about their experiences with Zoho and how it became an integral part of their everyday business life. In our recent episode, we had the opportunity to
      • Update on the upcoming Zoho User Group meetups - Q1

        Hey Zoho Community!  How're you all doing? We have an important announcement about the Zoho User Group meetups this quarter - Owing to the looming threat of COVID - 19, we're recalling several of our ZUG meetups that can't be run locally and are pulling back our Zoho teams who have traveled for these events. We have also suspended Zoho meetups run by our local partners and user group leaders as we do not want any of our users to come in harm's way. For those of you who have not seen the email about
      • Eighth day of Christmas - Zoho Recruit

        Check out the story behind our sixth day of Christmas post. ​ The eighth day of the 12 days of Christmas relates to Zoho Recruit  "On the eighth day of Christmas my true love sent to me: eight maids a milking, seven swans a swimming, six geese a laying, five golden rings, four calling birds, three french hens, two turtle-doves, and a partridge in a pear tree." The eight maids walking up with portfolios in their hands signifies Zoho Recruit's recruitment solutions built to provide diverse, end-to-end