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

2017/3/22

Create transparent circle

ironphoenix20 ironphoenix20

2017/3/22

#
Hi, I want to create a circle filled with a color but make it transparent. Also, I want to create two lines from he center of the circle to the topmost point? How do I do this?
Super_Hippo Super_Hippo

2017/3/22

#
So you want to draw a circle, but that circle shouldn't be visible? Or do you want a circle where you only see the border? Two lines from the center to the topmost point: Well, drawing one is fine, but drawing another one at the same position will still look like it would only be one.
ironphoenix20 ironphoenix20

2017/3/22

#
I don't actually want the circle to be transparent anymore. but the code for drawing a circle isn't working. this is what i have: public test() { GreenfootImage img = new GreenfootImage(75, 75); img.setColor(green); img.drawOval(0,0,75,75); img.fillOval(0,0,75,75); } this is my constructor by the way. Also, im going to be moving one of the lines so i do need two lines. How would i draw that?
Super_Hippo Super_Hippo

2017/3/22

#
Change 'green' to Color.GREEN' and remove the 'drawOval' line. You may also want to use the image.
setImage(img);
Moving lines on an image is not working. Then you need actors displaying the lines and let them move.
ironphoenix20 ironphoenix20

2017/3/22

#
Thanks. The circle now appears but how do I draw a line from the circle's midpoint to its topmost point?
Super_Hippo Super_Hippo

2017/3/22

#
img.drawLine(img.getWidth()/2, 0, img.getWidth()/2, img.getHeight()/2);
ironphoenix20 ironphoenix20

2017/3/22

#
How do I check if the line is being drawn or not? I tried to increase the length of the line so I can check bu no line appears.
Nosson1459 Nosson1459

2017/3/22

#
The line should be there, but you have to make sure that it's a different color than the circle.
public Test()
{
    GreenfootImage img = new GreenfootImage(75, 75);
    img.setColor(Color.GREEN);
    img.fillOval(0, 0, 75, 75);
    img.setColor(Color.RED);
    img.drawLine(img.getWidth() / 2, img.getHeight() / 2, img.getWidth() / 2, 0); // I changed the coordinates around because you (ironphoenix20)...
    // ...said "draw a line from the circle's midpoint to its topmost point"
    setImage(img);
}
The above code should draw a green circle with a diameter of 75 and a red line being/showing the radius.
ironphoenix20 ironphoenix20

2017/3/23

#
Thanks. It works now.
You need to login to post a reply.