Unit 2 Lab 2 Making Art by Using Data Structures

Mary was thinking of revisiting the culling arroyo at the bottom of the folio. --MF, 12/xvi/eighteen

ST EK List:
4.one.1H Different algorithms can exist adult to solve the aforementioned problem.
5.5.1H Computational methods may use lists and collections to solve problems.

Capturing Clicks as Points

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

PG: The /purpose/ of this (and the last) is never made articulate. Computers can aid us collect information. 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 paradigm and digitize item points that can later be used to reproduce the image or exist processed in another way.

MF: need to accost comments

On the previous page, you lot drew a shape based on a list of points yous were given. On this folio, you will automate the process of getting coordinates by clicking on the desired points on the screen.

Betsy and Alphie are still using coordinate lists to draw letters.

Take turns speaking

Alphie: Typing in all these coordinates is a pain. Let'due south write a program and so that if we have a picture, nosotros can click on the corners and let the program collect the coordinates?

Alphie: I have an idea, we can staple a picture to the screen.

Betsy: Great idea. And I know that we can import images as a stage background, so all nosotros have to practice is....

  1. Click here to load this file. Then save it to your Snap! account.
    Save Your Work Consign your new drawing blocks and abstruse data type from your "U2L2-DrawShape" project, import them into this new projection and salvage it again.

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

    Aren't import/export instructions given sufficiently on two.i.4--perhaps simply a reference here would exist plenty? --MF, 9/26/xviii

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

  2. Select a stage background of your selection.

Alphie: We'll accept to initialize the signal list variable to an empty list get-go.

Betsy: And nosotros know how to make the sprite follow the mouse; we did it in Unit of measurement 1.

Gamal: When we click, we should give the user some feedback that the click has been processed.

Alphie: What practice you lot mean? Like a sound?

Gamal: Maybe, merely I was thinking nosotros should mark each point somehow so nosotros feel confident the computer is recording our clicks.

Alphie: I accept an idea! There'southward a stamp block (in Pen) block that stamps a flick of the sprite right where information technology is on the stage.

Gamal: Not bad. And the Turtle sprite volition leave stamps pointing right where the user clicks.

Alphie, Betsy, and Gamal develop lawmaking to implement their ideas.

  1. The project file yous loaded contains 3 unfinished scripts, i for each of these steps. Finish all of these scripts.

    If you oasis't already, you'll demand to become dorsum to the Scripts tab and choose the "Sprite" button nether the stage to become back to the sprite's scripts.

    1. Get-go, 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. Supersede the forever block with one that volition loop only until the user presses the space key.
    3. In the third script, the postage stamp block is already in place, but you accept to write the lawmaking that will add the mouse's position to the list of points. Utilize your abstract data type. Save your work

For the purpose of inbound points interactively, the approach on this folio is all you need. But if yous wanted to create a more robust bespeak-gathering plan, this approach has a couple of weaknesses:

  • Even after you lot tell the sprite to stop following the mouse, the "when I am clicked" script is still ready to run, then if yous click directly on the sprite, it will still add points to the list. You may not want that.
  • The list of points is always kept in the same global variable. And then information technology'due south messy to create lists for several different messages.
  1. Think, and see if you tin can find your ain way to solve one or both of these problems.
  2. Here is an alternative arroyo that contains a new idea that y'all might similar. There are simpler solutions than this, but the idea behind this slightly more complicated lawmaking is a useful ane.

lopezpreavermy.blogspot.com

Source: https://bjc.edc.org/bjc-r/cur/programming/2-complexity/optional-projects/future/3-click-points.html

0 Response to "Unit 2 Lab 2 Making Art by Using Data Structures"

Post a Comment

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel