Question: For this project, create a class that represents a complex shape. Wherever the user clicks, create a new instance of your shape class and place


For this project, create a class that represents a complex shape. Wherever the user clicks, create a new instance of your shape class and place it where the mouse was clicked. Give it a random rotation and a random scale between 0.5 and 2.0. Track all of the shapes that you have created so far in an array.

Each click should produce a single shape.

The shape should consist of at least three primitive shapes.

The shape should exist alongside all of the previously placed shapes.

The shape should be produced at a random rotation and a random uniform scale. (Spoiler: you can either use the same number for both arguments of your scale() function, or just pass in a single number.)

The shape, when placed, should be centered where the mouse was clicked (or at least close) and it must not be distorted other than being uniformly scaled.

Every frame, you must clear the screen and redraw all shapes created thus far.

You must use a class for this assignment, and you must use an explict class declaration in a separate file, linked in to your project in the HTML.

Put as much functionality in your class as possible.

You are allowed to use more classes if you can make something easier.

Validate all assignments to properties in your class.

Scale should reject values outside of the 0.5-2.0 range.

Log a stack trace if this happens. Rotation should normalize to 0-360 degrees.

Position should clamp to the size of the screen.

Step by Step Solution

3.50 Rating (163 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

var xy var i1 let myshapes function printMousePos eventi xeventcli... View full answer

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 Programming Questions!