How to draw THIS ?

sorry to bother you with this “simple” problem

http://img18.imageshack.us/img18/1229/20034234.png

how to draw THIS ?

I thought about drawing a circle and then fill the rest with lines, but I am not that good with algorithms

note: you cannot cover up space you can only draw black
I use Java2D, so this would be with drawArc and drawLine and stuff

why not draw a black rectangle and then a white circle?

I said only black ? =)

because there are graphics behind this object which cannot be covered by white of course

btw so simplify the problem / algorithm

you can also draw this

http://img22.imageshack.us/img22/9201/so2.png

there is a border now, this is perfectly fine aswell

and obvisouly dont worry about anti-aliasing


Graphics2D g = ...
Area result = new Area(new Rectangle2D.Double(0,0,500,500));
Area cut = new Area(new Ellipse2D.Double(0,0,500,500));

result.subtract(cut);
g.setColor(Color.black);
g.fill(result);

Kev

oh nice, it was that easy afterall
well I didn’t thought there was a subtract method
really handy

That really sounds like a homework problem. Why else would you have such odd constraints?

Dunno, but he is around for some time and this could possibly be for his 2d game project, like masking out a light cone or something.

Good point :wink:

[quote] like masking out a light cone
[/quote]
100 points gentleman =D

however… if you are interested, I ended up with this:

g.setColor(new Color(0,0,0,200));
		
		g.fillRect(0,0,1024,500);    // above
		g.fillRect(0,650,1024,118);  // below
		g.fillRect(0,500,500,150);   // left of it
		g.fillRect(650,500,374,150); //right of it
		
		Point2D center = new Point2D.Float(575, 575);
     	float radius = 75;
     	float[] dist = {0.0f, 1.0f};
     	Color[] colors = {new Color(0,0,0,0),new Color(0,0,0,200)};
     	RadialGradientPaint p =new RadialGradientPaint(center, radius, dist, colors);
     
     	g.setPaint(p);
     
     	g.fillRect(500,500,150,150);

so basically using a RadialGradientPaint.

because I thought once I got the form I suggested I could easily do a disappearing gradient inside. But it turned out with … well. just ugly

yeah well this works, I might use it in some dark levels or something like that.