Having trouble on 1.4.2 Shape Properties on CMU CS Academy. I’m trying to make this shape. 1.4.2.1 Shape Properties checkpoint 2 Check Code Solution My Canvas Reset Code history Saved PEEQ BQ app.background = gradient(‘red’, ‘black’) 1 2 3 Star(200, 200, 210, 5, fill=’white’), roundness=40, dashes=True) 4. * Checklist X: 170 y: Console Clear The solution has three overlapping stars with dashed borders. Remember to use the Inspector to figure out the rotation of the black star and the roundness of the smallest star.
The Correct Answer and Explanation is :
Here’s the correct code for 1.4.2.1 Shape Properties Checkpoint 2 in CMU CS Academy:
app.background = gradient('red', 'black')
# Large black star (slightly rotated)
Star(200, 200, 210, 5, fill='black', border='black', dashes=True, rotateAngle=18)
# Medium white star (no rotation, dashed border)
Star(200, 200, 160, 5, fill=None, border='white', dashes=True)
# Small white star (rounded edges)
Star(200, 200, 110, 5, fill='white', roundness=40)
Explanation (300 words)
This exercise requires us to create three overlapping stars, each with different properties. Here’s how we achieve this step-by-step:
- Background Gradient
- We set the background to a red-to-black gradient using
app.background = gradient('red', 'black').
- Large Black Star (Base Star)
- We use
Star(200, 200, 210, 5, fill='black')to create the biggest star. - It has a dashed border, so we add
dashes=True. - The star is slightly rotated by 18 degrees, using
rotateAngle=18, making it look visually distinct.
- Medium White Star (Border Star)
- Next, we draw a slightly smaller white-bordered star with
Star(200, 200, 160, 5). - It does not have a fill, so we set
fill=Noneand addborder='white'to make only the outline visible. - This also has a dashed border (
dashes=True).
- Small Rounded White Star (Final Detail)
- The smallest star has
roundness=40, which gives it a softer, more curved look. - It’s filled solid white (
fill='white'). - It does not have a border or rotation.
Why These Choices?
- Using the Inspector Tool, we determine the rotateAngle of the largest star (18 degrees).
- The dashes are only on the large and medium stars.
- The smallest star has rounded edges with
roundness=40, making it stand out.
This ensures our solution matches the given requirements perfectly! 🎯