Answered step by step
Verified Expert Solution
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.
-
Start project using SNAP programming tool.
- 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.
- Create a constructor corner that will report a list of x and y coordinates of one corner.
- Create two selectors x of corner and y of corner that will report either the x or y values for an input corner.
- 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)
- 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.
- Create a global variable rectangle list to store the all the rectangles that have been drawn.
- 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).
- 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.
- 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
- 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
- repeatedly collects rectangles until the user is finished phase 1 (drawing) by:
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started