Link to final product:
https://editor.p5js.org/tina06c/sketches/_FLyYx5rU
Description:
For this project I created 5 functions that, when called together, creates the image of a bear-like creature. I created arrays for the x and y coordinates of the bear and the scale at which the bear should be drawn on the canvas. The length of the array is determined by the random function.
Final Result:
Coding:
For this assignment I first coded every single component of the creature all under the draw loop to see how they should look like combined together. Before discovering the scale() function I was initially trying to figure our the ratios between my shapes and then multiplying that ratio to their corresponding values. However, I soon realized that I can just use scale to change the sizes of my shapes proportionally. After doing that, I split each component into their own draw functions and all the body parts are called in the drawCreature() function where they make a final creatyre together. Link 1 was used to generate the colors needed.
Link 1:
https://www.rapidtables.com/web/color/RGB_Color.html
Reflections:
My project utilized three arrays; one for storing the x coordinate, one for y coordinate, and the last one for the scale of the creature. I occupied the arrays with a for loop and the length of each array is determined by a variable that gets its value from the random function. The arrays makes the creation of multiple creatures very easily and I used the arrays to help me see if my creature came out right even when the parameters changed. I used translate(), push(), and pop() for when I wanted to scale the shapes accordingly. User-defined functions allows me to organize my code based on their functionalities. The functions made my code easier to be read and understood by others and myself and the code looked a lot cleaner. The functions all had the parameters x, y, and scaleNum. The x and y were passed to the functions so that they know where to draw the shapes and the scaleNum is what determines how big the shapes were to be. It was a lot easier to find and manipulate specific parts of my code without worry that it will affect the other functions with the use of User-defined functions.
Leave a Reply