This site requires JavaScript, please enable it in your browser!
Greenfoot back
burmesekid
burmesekid wrote ...

2011/11/30

Graphics

burmesekid burmesekid

2011/11/30

#
So I have this project that I have to do and it deals with graphics. I'm supposed to draw lines, circles, rectangles, and random dots on the screen that's 600x400 pixel. The functions of the project include: 1. Draw dots in random places in random colors. 2. Draw lines in random lengths, in random places in random colors. 3. Draw circles in random sizes, in random places in random colors. 4. Draw rectangles in random sizes, in random places in random colors. 5. Clear the screen to white. 6. Clear the screen to a random color. 7. Toggle with the fill for the circles and rectangles. So lets say I hit a key, it will just draw the outline of the shape but if I hit it again, it will fill in the circles and rectangles. 8. Random letters (A-Z) appear on the screen in random places. There are 8 requirements that I need to meet but if I can get some help that will be great. If someone can tell me how to draw a line, I'm sure I can figure out how to draw circles and rectangles. The same with clearing the screen to white. I should be able to figure out how to clear the screen to a random color. Toggle tool and random letters are rather optional but if anyone can help me that would be greatly appreciated.
bourne bourne

2011/11/30

#
Look up the GreenfootImage api at http://www.greenfoot.org/files/javadoc/ There you will find the method signatures to draw different shapes and such. And note Greenfoot.getRandomNumber(number) returns a random number from 0 inclusive to 'number' exclusive. Take a look at this thread about getting random colors http://www.greenfoot.org/topics/find/3090#post_3090 And note the characters A-Z can be represented as ASCII values. The following will give you a String with a random letter in it (char)(Greenfoot.getRandomNumber(26) + 'A') + ""
burmesekid burmesekid

2011/12/5

#
thanks
You need to login to post a reply.