Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Q 2 : Simple Drawing Widget In this program, you have a gray background and a toolbox on the left side of the canvas. The
Q: Simple Drawing Widget
In this program, you have a gray background and a toolbox
on the left side of the canvas. The toolbox area is separated
from the drawing area by a vertical line. You have three
different shapes in the toolbox: a circle, a square and a
triangle Figure If the mouse is inside any of the shapes
in the toolbox, only that shapes color should change from
white to some different color pick a different color for each
of the three shapes as shown in Figure If the mouse is
clicked on one of the three shapes, then that shape should
become the chosen shape. When the mouse is clicked in the
drawing area, draw the chosen shape, centered on the
mouse position. But if any part of the shape would be drawn
in the toolbox area, then the shape should not be drawn. Its
OK to draw the shape partially off the canvas at the top,
right, or bottom, but not in the toolbox area.
Use the default canvas size of
The diameter of the circle is of the canvas size.
The height and width of the square is of the canvas size.
The distance from the top of the triangle to the base of the triangle is also of the canvas
size.
The toolbox area is of the canvas width.
The centre of all of the shapes are located at the centre of the toolbox.
There is a vertical gap before and after of each shape in the toolbox. This gap is of the
canvas size.
Figure : mouse is not inside any of the
shapes in the toolbox
Figure : mouse is inside the circle
area in the toolbox
Figure : mouse is inside the square
area in the toolbox
Figure : mouse is inside the triangle
area in the toolbox
ASSIGNMENT
COURSE NUMBER: COMP
Set the thickness of the stroke to
Make sure all of the components in the canvas scales up or down according to the canvas
size. For example, canvas size of X should produce the same results but in a
smaller scale.
Figure shows a sample drawing of the
shapes.
There should be only one method call in the
draw function which is drawToolBox
Create a void function drawToolBox that
is responsible for drawing and handling the
color change of the whole toolbox you are
allowed to create more functions to make the
task simpler
Use variables and constants of primitive data
types int float, boolean
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