Question: Hello, Please provide solution using SNAP programming NOT any other language. Start project using SNAP programming tool. In the drawing phase (phase 1), you will

Hello,

Please provide solution using SNAP programming NOT any other language.

  1. Start project using SNAP programming tool.

  2. In the drawing phase (phase 1), you will be drawing many rectangles by clicking and dragging from corner to opposite corner, so it will be helpful to have an abstract data type (ADT) to manage the corner points.
    1. Create a constructor corner that will report a list of x and y coordinates of one corner.
    2. Create two selectors x of corner and y of corner that will report either the x or y values for an input corner.
  3. Create two global variables to temporarily store the two points of each rectangle as it is drawn:
    • current corner 1: to store the coordinates where the mouse is first clicked
    • current corner 2: to store the coordinates where the mouse is moved as the rectangle is drawn (when the mouse is released, this value will be the final position of the second corner)
  4. Now create a rectangle ADT for storing the two opposite corners of a single rectangle.

Like in the Animation Studio project on the previous page, the stage will have to be cleared and redrawn many times so that the user can see each new rectangle changing in size as it drawn. The program needs a way to store all of the rectangles that have already been drawn so that they can be redrawn along with the current rectangle after each stage clear.

  1. Create a global variable rectangle list to store the all the rectangles that have been drawn.
  2. Your program needs a way to know whether the user is finished drawing. Create a global variable drawing done? that will store a Boolean value (either true or false) to keep track of the phase of the program (drawing or painting).
  3. The program also needs a way to draw a rectangle given its two defining corners. Create a draw rectangle block, and test that it correctly draws a rectangle with the input corners.
  4. Use the seven blocks and four variables you have created to create a program that:
    • repeatedly collects rectangles until the user is finished phase 1 (drawing) by:
      • collecting the coordinates of the first corner when the user starts to draw a rectangle
      • repeatedly collecting the coordinates of the second corner and redrawing that rectangle and all previous rectangles until the user releases the mouse to finish the rectangle
      • storing the final coordinates for each rectangle so they can be drawn again
    • uses a keystroke (like space) to tell the computer to switch to phase 2 (painting) and then fills the clicked areas
    Click for hints on creating this program.
    • Which variables need to be initialized? Why?
    • How can you detect the state of the mouse? How can you location the state of the mouse?
    • You might want to use and to improve the efficiency and appearance of your program. The warp block allows the drawing to happen quickly, and hide hides the sprite

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!