Lab 14: Fractals
Objective: To learn how Processing works and to apply recursion with fractals (using Processing’s
Fractals are geometric shapes that have patterns that repeat indefinitely, typically scaling smaller and smaller
in size. They have “fractional dimension”. Our goal is to create one of these via code.
However, we need a Graphical User Interface (GUI) of some sort. That’s where Processing comes into play.
Processing is a graphical li
other Java GUIs we can use like Swing or JavaFX, but the former is a tad outdated, and the latter isn’t easily
unnable in Replit (it’s too slow). Processing meets that perfect in-between standard of being easy to pick up
and relatively modernized.
1. Read ALL of the instructions before actually working on Step 2.
2. We need to understand how Processing works before we tackle fractals. Processing has both video
and text tutorials you can follow along with, though I would suggest at least going through Processing
a. Note that our version of Processing will look a tad different than what is shown in the tutorials
as we are using Replit as our IDE rather than using Processing’s built-in IDE.
. One of the key takeaways should be that while you can create shapes on the display window
with simple method calls (like how we did with CMU shapes last year in Comp Math), you can
structure your code via built-in methods – specifically setup() and draw().
3. Pick a type of fractal to simulate. Some examples of fractals are (totally not in order of difficulty from
least to greatest):
a. Fractal tree
. Cantor set
c. Sierpinski triangle
d. Koch snowflake (this requires an understanding of how to use a PVector in Processing)
Feel free to utilize Google or use the resources provided in Step 4 if you need some more information!
4. Write the code that makes the fractal you picked. The caveat: create your own version of the fractal
you are trying to simulate. Make it interactive, modify what recursive pattern you’re applying, combine
fractals – basically, the point is to play around with the general fractal design and understand how to
trace the algorithm.
a. Two fantastic resources are (1) the Examples that Processing has on its website, and (2) “The
Nature of Code” by Daniel Shiffman.
5. Find the Schoology assignment called “Lab 14: Fractals”. You should see a Google Doc embedded.
Write an essay explaining how you came about understanding the fractal you simulated. To provide
some level of guidance with what you should specifically write on, here are a few guiding questions:
a. What about Processing did you have to learn in order to make your fractal draw on the display?
What difficulties and struggles did you encounter, and how did you work them out?
. Explain step by step how the recursive nature of the code allows the fractal to work. Be
descriptive without using “fluff sentences.”
c. What specifically did you modify from the original fractal design? How did the change affect
the level of difficulty in updating your code?
There is no page minimum or maximum, but be mindful how many points are ascribed to the essay
(see the grading ru
ic on the next page).
You may use bullet points and/or images if they assist you in explaining your work!
If you feel an essay is restricting, feel free to ask me about utilizing a different medium (video,
PowerPoint presentation, etc.)
• The point of this lab is two-fold: (1) learn the methods of a new li
ary we may not have used before,
and (2) understand how to trace recursive code and explain the logic behind it. While I do not condone
plagiarism and claiming someone else’s work as yours, you are more than welcome to use existing
code to help you understand better what you want to do. Tread the line carefully and don’t cross it!
• The open-ended nature of this lab should foreshadow what the Q4 lab(s) will look like…
When your source code is completed, make sure to submit the lab on Replit AND submit the essay in
Code demonstrates a fractal of your choice with a level of variance (interactive, modification of
ecursive pattern, etc.)
Essay describing the code is organized and clearly (and concisely) explains the logic 10
All instructions have been followed from the previous pages 2
Output is formatted neatly and in an organized fashion
Code is commented appropriately
Variables are organized accordingly and named meaningfully