Interactive Drawing

My drawing program

Our task was to create a program that would allow the user to draw using their mouse and cursor. In my program you can use the top row of letters to change the color of the stroke and you can use the up and down arrows to adjust the width of the stroke. Making the original code to create a line at the location of the cursor was relatively simple to figure out, then I just needed to change it to  only run the function if the mouse was pressed and not all the time. After that I used the keyPressed function to give my program the function to change the color of the stroke, and then adding keys to adjust the width of the line that’s being drawn. The toughest part of  the coding was figuring out how to create a function that generates random colors every time the key is pressed. I ran into many problems trying to create randomly generated colors because it kept giving me random colors on the greyscale. To resolve this problem I had to rename my variable for color, and  add three more variables each of which would generate a random color. After creating all of the keys to change the drawing I added a reset button that when pressed would make the background white again. I also added a rectangle in the top left of the screen that would display what color you were currently drawing with, this is to help the user see what random color was without having to draw a line. The one thing I was trying to add that I couldn’t quite figure out was an input field where the user could input their own custom color. I wasn’t  able to figure out how to store the figures that were input and then use them as a variable to create a color. Overall I think the program offers a good and relatively easy experience to the user and this project was a very good learning experience for me.

Leave a Reply

Your email address will not be published. Required fields are marked *