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

2016/4/12

How do I draw a rectangle whitout fill?

GreenBat GreenBat

2016/4/12

#
Help me please! GreenfootImage image = new GreenfootImage(50, 50); image.drawRect(50, 50, 50, 50); image.setColor(java.awt.Color.BLACK);
danpost danpost

2016/4/12

#
The first two parameters of the 'drawRect' method are the location coordinates that the rectangle is to start from on the image it will be drawn on. It is the location where the top-left corner of the rectangle will be. If you place the top-left corner of a rectangle below and to the right of the image, none of the rectangle will be drawn on the image itself. Btw, a new GreenfootImage will have a default drawing color of black; so the last line is not needed:
image.drawRect(0, 0, 50, 50);
This line starts the rectangle at the top-left corner of the created image and gives the size of the rectangle as 50x50.
You need to login to post a reply.