First, the link to my sketch on p5.js Web Editor

– For this sketch, I was heavily inspired by psychedelic art. I’ve always loved the bright neon colors and somewhat chaotic mix of shapes and objects, and of course, I adore the mushroom motif that is common in many drawings. I found enjoyment looking online for inspiration. Some photos I drew inspiration from are shown below:





– I think that creating many different shapes, colors, and patterns that is required of the psychedelic aesthetic is fitting for creating many different functions and arrays (examples of this in my code discussed below). To create the chaotic look, the scale, the position, and the color of each individual part of the mushroom (top, underside, spots, stem & arms) is randomized for each mushroom drawn. The mushroom has the anatomy of a real life mushroom, but it also has a cartoony face and arms. The body of the mushroom oscillate along the y-axis, the arms oscillate according to the rotation of its endpoint, and its size also oscillates in the scale( ) function; all features were accomplished with a preset speed variable and the sine function. A screen recording of the animation is provided below:
– The first thing I tackled was the background. I found that since the background utilizes many for Loops, the sine function, and the environmental variable frameCount, actually drawing the background in the draw( ) block of this sketch was too difficult for the Web Editor to handle. The animation was very slow. Hence, this sketch is actually two of my sketches put into one. Meaning, I created a new sketch called “green_wave”, which only consisted of the background code, and saved it in a folder called “images” in the Web Editor. Then in the original sketch with the mushrooms, I uploaded the background using function preLoad ( ) and image( ). After adding this, the animation ran very smoothly. Here code for the “green_wave” sketch:
Now, here is the code for uploading this image into the original sketch:


– Next, in order to randomize the scale and position of the mushroom, I initialized various arrays before function setup( ) and then filled them with random values in function setup( ). The size of these arrays is 15, for 15 mushrooms:


– The method for randomizing the colors was a little different. I didn’t want to just use random( ) to call random color values; I had a specific color palette in mind. The following images include some of the colors I used:



Hence, I initialized an array called “theme” before setup( ), and inside setup( ) I created a total of 18 elements in the “theme” array that were each a unique color value: 

– Finally, when it came time to draw the mushrooms in the draw loop, randomizing their features was simple. I first created variables for the mushroom’s x position, y position, size scale, width scale, and colors by accessing random values in the corresponding arrays. For the colors, since I wanted each part of the mushroom to have a different color, the variables “stem_col” for the stem, “top_col” for the mushroom top, “under_col” for the mushroom top’s underside, and “dot_col” for the spots on the top were created by calling random values from the “theme” array. The sequence of if-statements is to ensure that a color is not repeated. Finally, function drawMushroom and function drawFace is called, passing all the above arguments into it:

– When it came to drawing the individual parts, it was fairly simple with the help of the translate( ), scale(), and push( ) / pop( ) functions. In particular, the translate( ) and scale( ) function allowed the mushrooms to move up and down as well as grow and shrink, since their values both includes an added speed variables. The code is shown below:
in function draw():
![]()
in function drawMushroom( ):

– The most difficulty I experienced was drawing the mushroom top and stem, as I had to use the curveVertex( ) function in order to create the dynamic shapes. In addition, given the dynamic curves, drawing the spots was definitely a guess-and-check procedure, moving and rotating each spot meticulously to mimic the effect of spots drawn while being constrained by the curve shape.
– Finally, the feature I think that really made the psychedelic aesthetic come to life was the changing colors as it animated. The process for creating this effect was somewhat experimental. At first, I used randomSeed( ) in the draw loop to ensure that the colors would not change every frame, but once I removed randomSeed(), I felt that the flashing colors were quite cool and fitting with the vision I was going for. However, having the random function be called every frame is obviously quite jarring on the eyes. Hence, my solution initialize a variable called “seed” before setup( ), and then change the seed value according to the frame count. Then, randomSeed(seed) would be called in the draw loop. The code is shown below:
in function setup( ): ![]()
in function draw( ): 
REFLECTIONS:
– As I learned from coding this sketch, the translate(), push(), and pop() functions are extremely useful when drawing multiple objects, and when calling multiple functions. It allows the programmer to not have to deal with too many numbers and to take advantage of variables created once.
– The main benefit of creating user-defined-functions is obviously the creativity the programmer has to draw, write, perform anything they want. When creating functions, the sky really is the limit. Additionally, user-defined-functions help organize the code into separate, smaller tasks, so that whoever reads your code or needs to modify it will have no difficulty understanding what it means.
– As mentioned above, some parameters I included in my functions were the x and y positions, scale values, and color values. All of these worked together to draw each and every mushroom uniquely.
– For some parts of the mushroom, such as the radial lines drawn on the underside of the mushroom and the face, I did not want some parameters, like the scale values, to have effect on these parts. Hence, creating separate functions to draw the face and the radial lines helped immensely to ensure the scale effect was only applying to certain parts of the overall drawing.

