Creating Floral Masterpieces with p5.js
Step 1: Setting Up the Canvas
In this step, we begin by creating a canvas to draw on. The `setup` function initializes the canvas with a width and height of 400 pixels each. Additionally, we set the background color to a pleasant light gray tone.
Step 2: Drawing the Stem
In the `draw` function, we focus on drawing the stem of the flower. The `stroke` function defines the stem's color as green, and we set the stroke weight to make it bolder. Using the `line` function, we draw a line that starts at coordinates (200, 300) and ends at coordinates (200, 200), forming the flower's stem.
Step 3: Drawing the Petals
Continuing from the previous block, we move on to drawing the flower's petals. Using the `fill` function, we set the color to a warm yellow shade. To achieve a petal-like appearance, we use the `ellipse` function to draw six ellipses at the top of the flower. The `rotate` function helps rotate the petals around the center, forming a circular pattern.
Step 4: Adding the Flower's Center
Lastly, we complete our flower by drawing its center. With the `fill` function, we set the color to a vibrant red. Using the `ellipse` function again, we create a smaller ellipse at the center of the petals, representing the heart of the flower.