ST EK List:
1.2.3A Creating computational artifacts can be done by combining and modifying existing artifacts or by creating new artifacts.
5.3.1 Use abstraction to manage complexity in programs. [P3]
5.3.1E Parameterization can generalize a specific solution.
5.3.1F Parameters generalize a solution by allowing a function to be used instead of duplicated code.
5.3.1G Parameters provide different values as input to procedures when they are called in a program.
MF: 1.2.4 Collaborate in the creation of computational artifacts. [P6]

Remix Your Pinwheel

Ruthless Suggestions from Al

On this page, you will use your existing pinwheel block to make asterisk and polygon blocks.
Animation cycle from Asterisk to Polygon

You can use your general-purpose pinwheel procedure to create other, simpler special-purpose procedures that each do a particular job.

Asterisk with 12 branches
  1. If it isn't open already, open your U1L3-Pinwheel project from the previous page.
  2. Use your pinwheel block to create a more specialized asterisk block.
    1. First, make a new block called asterisk with two variables: one for the number of branches and one for the length of each branch. You may wish to review how to make a new block at Unit 1 Lab 2 Page 3: Making Your Own Block.
    2. asterisk, branches:(branches) branch length:(length){pinwheel, branches: ( ) size:( ) backup:( )}
    3. Now fill in the three inputs to pinwheel so that it correctly draws an asterisk.
Pair Programming Swap
  1. Similarly, write a polygon block that uses pinwheel with appropriate inputs to draw a polygon with a given number of sides and side length.

Using a block you've already written to help write another block is an example of abstraction. Abstraction is arguably the most important idea in computer science, but it doesn't have a simple definition. Here, abstraction means using a more general block (pinwheel) to create two more specific blocks (asterisk and polygon). There are other kinds of abstraction too, and we'll point them out as they come up.

In the meantime, if you find yourself wanting to copy code from one place to another, consider abstracting by writing a general block to use in both places instead.

    Look at the Polygonal Racetracks activity for insights and practice on polygons.
    Polygonal Racetrack angles
  1. If you look inside of pinwheel and see how you're using it in polygon, you'll see that there are steps that you don't really need for the case of a polygon. Write another version of polygon built directly out of primitive blocks (move, turn and so on). How simple can you make it?
Now Is a Good Time to Save
  1. Use your pinwheel block code one last time to create a circle block that accepts one input for the size.
  2. Use the random block together with set pen color and set pen size to draw a variety of shapes.
    assortment of pinwheels
 
  1. Challenge: Create a script that draws a blue square of size 100 and then draws a red circle that fits perfectly inside it.
    red circle in blue square
  2. In each of the puzzles below you will need to write code that will allow a car to travel from its starting point (A) to its final destination. Click on each of the images to load each Snap! project.
    Triangle and square tesselation path Triangle, square and hexagon tesselation path Octagon and square tesselation path