For my Nature of Code midterm, I wanted to make something interactive with a personal takeaway. Looking for inspiration, I was poking around on etsy when I found these light and sweet gouache paintings from Once Upon a Paper. Her paintings are of trees with ellipses as leaves, and I immediately wanted to recreate them using Processing. Here are a few examples of her work:
Unlike the static painting, I want the user to add their own leaves, and for each tree to be unique. I started with Dan Shiffman’s Stochastic Tree sketch, which draws a tree based on angles and theta rotation. Using the Box2D library, I created an array of ellipse leaves that show up when the mouse is pressed, have varied sizes and colors, and are attracted to two specific points on the tree. This gives the appearance of the leaves sticking to the branches. Pressing a specific key clears the leaves, and the user can start over.
The Box2D library is robust, but I met challenges with not knowing the syntax. Specific calls have changed over the past year, and much of the documentation I found online is out of date. Thank goodness for office hours with Dan Shiffman. Some screenshots of the process:
- The ultimate goal for the project is that on mouse click, leaves will either attract to the branches, or will fall to the ground. As of right now, gravity is completely turned off so that the leaves will attract to the branches. By redesigning the tree and keeping track of all of the branch points in an array, I will be able to make those specific points attractors. If a leaf is created outside of the attractor’s pull range, it will fall to the ground.
- The tree in my sketch looks very little like the trees in the paintings, and I want to redraw it in a way that is less angular.
- As with the clearing of the leaves, I want the user to create a new tree and branches, as well. I have that commented out in the code for now, as I focused primarily on getting the attractors set for the midterm.