Answered step by step
Verified Expert Solution
Link Copied!
Question
1 Approved Answer

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

Step: 1

blur-text-image
Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Spatio Temporal Database Management International Workshop Stdbm 99 Edinburgh Scotland September 10 11 1999 Proceedings Lncs 1678

Authors: Michael H. Bohlen ,Christian S. Jensen ,Michel O. Scholl

1999th Edition

3540664017, 978-3540664017

More Books

Students explore these related Databases questions