Link to p5.js editor: https://editor.p5js.org/kh1785/sketches/qkz-D0y-_
The sketch for this week was developed from the first two assignments, the cocktail illustration/animation. The primary goal for this assignment was to make setup and draw functions as clean as possible with the beauty of the function.
First of all, I made the cocktail glass into a function and set several different parameters. I set the x and y parameters of translate as the parameters of the function so that I can easily alter the location of each cocktail glass. For other parameters, 'length' and 'Color', I used the random function to allow subtle randomness to happen. Basically, the parameter 'length' determines the height of the liquid and the parameter 'Color' enables a shuffling of the color of each cocktail. Pressing the down arrow key allows the shuffling of those two parameters. Depending on the color, the name of the cocktail is determined and the name also appears at the bottom of each cocktail glass.
There are five cocktails (Blue Lagoon, Jack Rose, Midori Sour, Old fashioned, and Screwdriver) and pressing the keyboard keys (b: Blue Lagoon, j: Jack Rose, m: Midori Sour, o: Old Fashioned, and s: Screwdriver) reveals the corresponding cocktail recipe. Those recipes are loaded image files, which were marked in the preload function. Pressing the h key allows the user to return to the home page.
Comments