Page 1 of 1

a) Copy the MouseMoveGraphics project from Week 5 into your Week 6 folder and then open the project Create a variable ca

Posted: Sat May 14, 2022 6:35 pm
by answerhappygod
a) Copy the MouseMoveGraphics project from Week 5 into your Week
6 folder and then open the project Create a variable called size in
the MouseMove event method of the picturebox. Inside the if
statement before you draw anything store a random value between 0
and 50 in the size variable. Then use the size variable for the
width and height for each method call. This means a new circle size
is generated when the mouse moves. Test the application. b) Having
all the circles in the same colour is a bit bland. You will now
generate a new colour for the SolidBrush before drawing the
circles. You will use the FromArgb method to generate a new colour
value. The method is passed 3 values (a value between 0 and 255) to
represent the Red value, the Green value and the Blue value of a
colour. Before drawing the circles type in: br.Color =
Color.FromArgb(?, ?, ?); You need to replace each '?' with a
different random value between 0 and 255 (inclusive). Do not use
the same random value for Red, Green and Blue as this will give you
a grey colour. Run and test the application. c) You will now
extend the code so that when the mouse is pressed it will draw a
random number of circles around the mouse pointer with their
positions slightly different from each other. The pseudo-code is:
IF left mouse button is pressed THEN Generate a random number of
circles between 5 and 10 Set counter variable to 1 WHILE counter
<= number of circles to draw Generate a random number between 2
and 10 for the size of the circle Store xPos = mouse X + random
number between -10 and 10 Store yPos = mouse Y + random number
between -10 and 10 Draw ellipse at xPos and yPos position Add 1 to
counter variable ENDWHILE ENDIF Modify the MouseMove event for the
picturebox so that it matches the pseudo-code above. Run and test
your application. Congratulations! You have now created your very
own custom airbrush tool that you have complete control over. Try
producing some art using the tool. Be careful as there is no undo
tool if you make a mistake. Press the PrintScrn button on the
keyboard to copy your screen and then open MS Paint and paste the
screen into Paint and save it as a jpg file. Post the image in the
Artwork thread in the Paper Discussion forum on Moodle and the best
ones will win some chocolate!.