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

2017/2/18

How to paint a circle in Greenfoot

wueschn wueschn

2017/2/18

#
I want just to paint a circle without given Circle Picture. So I just started with a new Class without picture. Then I try this code, but it does not work.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
import greenfoot.*; 
public class Balls extends Actor
{
    public Balls()
    {
        GreenfootImage image = new  GreenfootImage(70, 70);
        image.setColor(Color.RED);
        image.drawOval(100, 100, 70, 70);
        image.fillOval(100, 100, 70, 70);
        this.setImage(image);
 
    }
 
    public void act()
    {
        // Add your action code here.
    }   
}
Thanks for your help!
Super_Hippo Super_Hippo

2017/2/18

#
Try to use 0 instead of 100. Right now, you are trying to draw the circle outside of the image.
wueschn wueschn

2017/2/19

#
@Super_Hippo Thanks a lot, it works perfect. I just misunderstood the x and y parameter of the drawOval method .....
You need to login to post a reply.