Mary was thinking of revisiting the alternative approach at the bottom of the page. --MF, 12/16/18
ST EK List:
4.1.1H Different algorithms can be developed to solve the same problem.
5.5.1H Computational methods may use lists and collections to solve problems.

Capturing Clicks as Points

Page name here does not match topic page. Need to check TG too. --MF, 6/27/18

PG: The /purpose/ of this (and the last) is never made clear. Computers can help us collect data. Sometimes, we want to pull the data off of an image: of a graph, a letter, the coordinates of features of a face, the measurements of some bridge…. This lesson shows how to import an image and digitize particular points that can later be used to reproduce the image or be processed in some other way.

MF: need to address comments

On the previous page, you drew a shape based on a list of points you were given. On this page, you will automate the process of getting coordinates by clicking on the desired points on the screen.
Jasmine and Morgan are still using coordinate lists to draw letters.
Take turns speaking
Morgan: Typing in all these coordinates is a pain. Let's write a program so that if we have a picture, we can click on the corners and let the program collect the coordinates?
Morgan: I have an idea, we can staple a picture to the screen.
Jasmine: Great idea. And I know that we can import images as a stage background, so all we have to do is....
  1. Click here to load a starter project. Then save it.
    Save Your Work Export your new drawing blocks and abstract data type from your "U2L2-DrawShape" project, import them into this new project and save it again.

    Clarify these instructions (about importing and exporting), and include the necessary content cut from "Importing Greet Player into Another Program." --MF, 6/18/18

    Aren't import/export instructions given sufficiently on 2.1.4--perhaps just a reference here would be enough? --MF, 9/26/18

    Is the commented out text here still needed? --MF, 9/26/18

  2. Select a stage background of your choice.

    Setting the Stage Background

    1. Click the Stage button below the actual stage.
      stage button in sprite corral
    2. Click the "Backgrounds" tab near the top of the window.
      I cropped this image because it was distractingly long unnecessarily. --MF, 3/4/19
      backgrounds tab
    3. Select or import a stage background. In this project, you will find two imported backgrounds:
      • A graph of median U.S. household income by year (source: Federal Reserve Bank of St. Louis)
      • A capital "E" (font: Century Gothic Bold).
      • The graph is typical of data processing, which is one topic of Unit 3. The E continues the activity from the previous page. Choose either background by clicking on it.
Morgan: We'll have to initialize the point list variable to an empty list first.
Jasmine: And we know how to make the sprite follow the mouse; we did it in Unit 1.
Omar: Yes, and every time we click, we want to add the position to a list as we did in the Unit 1 "Greet Player" project.
We cut the Unit 1 "Greet Player" project. --MF, 12/16/18
Omar: When we click, we should give the user some feedback that the click has been processed.
Morgan: What do you mean? Like a sound?
Omar: Maybe, but I was thinking we should mark each point somehow so we feel confident the computer is recording our clicks.
Morgan: I have an idea! There's a stamp block (in Pen) block that stamps a picture of the sprite right where it is on the stage.
Omar: Great. And the Turtle sprite will leave stamps pointing right where the user clicks.
Morgan, Jasmine, and Omar develop code to implement their ideas.
Entering points for E
  1. The project file you loaded contains three unfinished scripts, one for each of these steps. Finish all of these scripts.
    If you haven't already, you'll need to go back to the Scripts tab and choose the "Sprite" button under the stage to get back to the sprite's scripts.
    1. First, give an appropriate initial value to the point list variable.
    2. In the second script, you need a way to tell the sprite to stop following the mouse. Replace the forever block with one that will loop only until the user presses the space key.
    3. In the third script, the stamp block is already in place, but you have to write the code that will add the mouse's position to the list of points. Use your abstract data type. Save your work

For the purpose of entering points interactively, the approach on this page is all you need. But if you wanted to create a more robust point-gathering program, this approach has a couple of weaknesses:
  1. Think, and see if you can find your own way to solve one or both of these problems.
  2. Here is an alternative approach that contains a new idea that you might like. There are simpler solutions than this, but the idea behind this slightly more complicated code is a useful one.