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

2015/5/17

Help with drawOval

Buddha Buddha

2015/5/17

#
I'm trying to create a border around a circular object, and I wanted to know how I could make said border thicker when using the drawOval method.
danpost danpost

2015/5/17

#
Could you not create a new image of appropriate size (image size plus twice the border width), draw (fill) an oval on it and then draw the image of the circular object, centered, on it?
Buddha Buddha

2015/5/20

#
My problem was that the Greenfoot drawOval method only allowed a width of one pixel. I solved it by using Graphics2D methods.
danpost danpost

2015/5/20

#
I was suggesting something like this:
1
2
3
4
5
6
7
8
9
10
11
int borderSize = 10; // adjust as needed
Color borderColor = Color.black; // adjust as needed
GreenfootImage image = getImage();
int newWidth = image.getWidth()+2*borderSize;
int newHeight = image.getHeight()+2*borderSize;
GreenfootImage newImg = new GreenfootImage(newWidth, newHeight);
 
newImg.setColor(borderColor);
newImg.fillOval(0, 0, newWidth-1, newHeight-1);
newImg.drawImage(image, borderSize, borderSize);
setImage(newImg);
You need to login to post a reply.