Microsoft Word - Assignment Instructions_6.docx
Assignment Instructions
All code must be done in the processing software. Free software download on
processing.org
Will need 4 global variables :
1. startX
to store the x coordinate of the starting position of cu
ent shape being drawn
2. startY
to store the y coordinate of the starting position of cu
ent shape being
drawn
3. cu
entColor
to store color of the cu
ent shape of cu
ent shape being drawn
4. cu
entShape
to store user's choice of cu
ent shape being drawn
Will need 6 parallel a
ays that need to be declared globally - each one to capture the aspect
of the shape that is being drawn ( feel free to use short forms like fcX or x1).
1. firstcornerX
to store x coordinate of the first corner of a shape
2. firstCornerY
to store y coordinate of the first corner of a shape
3. secondCornerX
to store x coordinate of the second corner of a shape
4. secondCornerY
to store y coordinate of the second corner of a shape
5. colors
color of a shape
6. shapes
to capture the type of a shape
In mousePressed :
1. save cu
ent mouse locations into appropriate variables startX, startY.
2. generate a random color and store it in the variable cu
entColor.
3. save user's choice of shape inside the variable called cu
entShape depending on the
mouseButton. i.e. if user pressed LEFT mouse button then you would store 1 for
ectangle and 2 for ellipse.
In mouseReleased: (user has finished determining the size of the object - so time for us to store
the info into a
ays):
store the info regarding cu
ently drawn shape into appropriate a
ays.
In mouseDragged :
1. clear the canvas (that helps us to remove the drag lines).
2. draw all existing shapes by using info stored in the parallel a
ays (use a for-loop).
Do the following inside the for-loop :
a. fill with i-th elemtent's color taken from a
ay colors
. determine i-th element's shape taken from the a
ay shapes and write code to
make the appropriate shape .
3. Now that you have drawn all the existing shapes, it is time to reflect the user's actions.
a. fill with the cu
entColor
. determine which shape needs to be drawn and accordingly call the rect or ellipse
(this is info is available in the variable cu
entShape and it's value should have
een determined in step 3 of mousePressed ).
Lavf XXXXXXXXXX