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

2013/4/27

Shapes

Gingervitis Gingervitis

2013/4/27

#
I have been exploring the Greenfoot documentation page and I saw there is a fillShape(). How do you use this?
Gevater_Tod4711 Gevater_Tod4711

2013/4/27

#
This method draws an object which type is shape and fills this object with the current drawing color. Shape is an interface from java.awt: java.awt.Shape API. Because It's an interface you can't create a Shape using the new operator but every class that implements this interface is also known as a Shape and you can use it. In the API you can see all known implementing classes. All of them can be used as the parameter of this method.
Gingervitis Gingervitis

2013/4/27

#
how would the parameters be set up for this?
Gevater_Tod4711 Gevater_Tod4711

2013/4/27

#
You just need an object from any class that implements java.awt.Shape. For example this would be a solution:
GreenfootImage img = new GreenfootImage(100, 100);
img.fillShape(new Polygon());
Of course that wouldn't make much sence because the polygon is empty but if you use a different constructor for Polygon (like ,%20int,%20int%29]this one) this polygon will be drawed onto your GreenfootImage.
Gevater_Tod4711 Gevater_Tod4711

2013/4/27

#
Hmm... a realy strange link. Probably because of the brekets.
You need to login to post a reply.