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

2012/2/20

Cutting Images

1
2
kiarocks kiarocks

2012/2/20

#
Idk if this is a good place to ask, but how would i cut out a shape like this http://i1094.photobucket.com/albums/i442/kiavoldemort/Coal-1.png from another image?
danpost danpost

2012/2/20

#
Two ways, I can immediately come up with: (1) Either make all the interior (preferred), or all the exerior a specific color, and then for each pixel, if it is (or is not) that color, change the color of the current pixel inside to the color of the same pixel in the other image. (2) refer to Clipping images
kiarocks kiarocks

2012/2/20

#
I am doing this not in greenfoot, so how does drawPolygon work?
kiarocks kiarocks

2012/2/20

#
And how could i make the picture a Shape?
kiarocks kiarocks

2012/2/20

#
NVM! I could just figure out the coords need to make the Polygon, and use that.
kiarocks kiarocks

2012/2/20

#
Ok, how do you check if there is a file in a folder, and if there is, load it?
danpost danpost

2012/2/20

#
If you know the name of the file already, use 'try'/'catch' and try to open it. If it opens, load it.
kiarocks kiarocks

2012/2/20

#
I figured that out, but once i open the (java.io)File how do I save it when I'm done?
danpost danpost

2012/2/20

#
I guess you need to check out the tutorial on file ops.
kiarocks kiarocks

2012/2/22

#
Got it, just working out how to make a file with polygon points in it
danpost danpost

2012/2/22

#
The easiest way is to have an initial integer for the number of points and then either (1) all the x-coordinates followed by all the y-coordinates, or (2) alternate x-coordinate and y-coordinate for each point in the polygon. This way, when reading the file back, after the first integer is read back in, it can be used to determine how many more integer values need to be read back in for the polygon coodinates.
kiarocks kiarocks

2012/2/22

#
Im gonna see what i can come up with.
kiarocks kiarocks

2012/2/22

#
maybe { { 1 ,1,2,5,7,9} , {3,8,1,7},{4,9,3,7}}
Builderboy2005 Builderboy2005

2012/2/22

#
There is a Polygon class, which is a subset of the Shape class, that has all of your polygon functionality built in. Shapes are also compatible with Graphics2D, making it easy to draw polygons of your own.
kiarocks kiarocks

2012/2/22

#
I need to save the polygon and load it later.
There are more replies on the next page.
1
2