0

Hi I'm making a flash light for a game. I make the flashlight using Arc2D and basically clip part of the map so that only that part shows up, but I also want part of the map to so up too.

Is there anyway to reverse my clipped region and get the region not being clipped? enter image description here

How do I get the black region?

noobycoder
  • 63
  • 2
  • 13

1 Answers1

0

You can use the Area#subtract method to obtain the desired area:

Rectangle2D screen = 
    new Rectangle2D.Double(0,0,screenWidth, screenHeight);
Area result = new Area(screen);
Area clippingArea = new Area(yourArcClipShape);
result.subtract(clippingArea);

The result will then be the shape of the full screen, except for your original "arc" clipping shape - that is, the black area in the image.

Related answers, showing some light effects and image compositing:

Community
  • 1
  • 1
Marco13
  • 53,703
  • 9
  • 80
  • 159