In this lab you write functions to create different shapes: rectangles, triangles, and circles. You will then use your functions to create a picture.
-
Implement the following functions
- drawRectangle -- this is done for you, but it isn't quite right!!
- drawTriangle
- drawCircle
-
Practice calling your functions using different parameters to make sure they work correctly
-
Modify the drawRectangle function your wrote so that you can add text to the rectangle in a different part of your program. Do this by adding a return statement to return the rectangle variable.
-
Declare a new variable (call it whatever you want). Then call drawRectangle and assign it to this new variable (see the code snippet below). Add text to your rectangle.
var myRectangle = drawRectangle(200, 10, 10);
-
Modify the drawCircle function your wrote so that you can change the background color of the circle in a different part of your program. Do this by adding a return statement to return the circle variable.
-
Declare a new variable as before, then call drawCircle and assign it to this new variable. Use the backgroundColor property to change the background color of the circle.
- Create triangles with different colors by replacing null with a color when you call makeTriangle. For example, the following code snippet would draw a pink triangle,
drawTriangle(100, 200, 200, "transparent", "transparent", "transparent", "pink");
- Create a picture of a "Winter Scene" using the functions you wrote. Your final image should incorporate at least 10 different elements and clearly resemble an image.