1 What image do you see repeated in the flag?
2 In the code below, highlight or circle all instances of the expression that makes the repeated image.
china =
put-image(
rotate(40,star(15,"solid","yellow")),
120, 175,
put-image(
rotate(80,star(15,"solid","yellow")),
140, 150,
put-image(
rotate(60,star(15,"solid","yellow")),
140, 120,
put-image(
rotate(40,star(15,"solid","yellow")),
120, 90,
put-image(scale(3,star(15,"solid","yellow")),
60, 140,
rectangle(300, 200, "solid", "red"))))))
3 Write the code to define a value for the repeated expression.
4 Open the Chinese Flag Starter File and click "Run".
-
Type
china
into the Interactions Area and click Enter. -
Save a copy of the file, and simplify the flag code using the value you defined.
-
Click "Run", and confirm that you still get the same image as the original.
-
Now change the color of all of the stars to black, in both files.
-
Then change the size of the stars.
5 Why is it helpful to define values for repeated images?
Challenge:
-
This file uses a function we haven’t seen before! What is it?
-
Can you figure out its contract? Hint: Focus on the last instance of the function.
These materials were developed partly through support of the National Science Foundation, (awards 1042210, 1535276, 1648684, and 1738598). Bootstrap by the Bootstrap Community is licensed under a Creative Commons 4.0 Unported License. This license does not grant permission to run training or professional development. Offering training or professional development with materials substantially derived from Bootstrap must be approved in writing by a Bootstrap Director. Permissions beyond the scope of this license, such as to run training, may be available by contacting contact@BootstrapWorld.org.