Simple Paint Program Issue

Posted 22 February 2012 - 10:28 AM

Hi,

Im in the process of making a paint application for my class and I'm currently having some difficulty with getting the freehand drawing tool to work (Which is basically just drawing many small squares). We have been told to use arrays in which will hold different information such as position, size, color, etc as shown below.

However Im now not sure how I get from here to actually drawing these small squares on the screen. Ive used the g.fillRect method in the past so I'm guessing this could be used but im just struggling with bringing all this together.

Re: Simple Paint Program Issue

Re: Simple Paint Program Issue

Posted 22 February 2012 - 12:26 PM

Ive looked at a few different basic paint apps and not many of them use arrays like I am in this program. I understand that this probably isnt the most efficent thing to do but I have to use them in this case.

Re: Simple Paint Program Issue

Posted 23 February 2012 - 07:34 AM

Cheers pbl that helps.

One question I've got which may seem like a stupid one is how can I get the values ive got in a 2d array and then have these points drawn using the g.fillRect method. Ive done some basic shape drawing using this method, i.e g.fillRect(20, 30, 200, 100), but I'm struggling with getting array values to print out in this way.

How would i go about only drawing on the canvas when a particular radio button is selected? I know im going to need some form of listener but I've played around with this and cant seem to get it to work.