0

I have looked into using the EVEN-ODD Winding rule in order to create holes in an area. The thing is on the forum all I could come up with was a Path2D.Double() appending a hole within itself. I want to create a whole in an already existing Path2D much like the Area class has the Area.subtract(new Shape()); does. I am desperate. I know Path2D has the ability to improve the performance of my game.

Path2D.Double d = new Path2D.Double(Path2D.WIND_EVEN_ODD);// this is a much larger circle which I will be using to subtract from the tile...

d.append(current_draw_area.createTransformedArea(mouse_point), false);//Note that this is an area without a winding rule...

Path2D.Double shape= new Path2D.Double();//this is actually a empty tile which is simply a rectangle, but will eventually have something in it to subtract from...

shape.append(d, false);

Note: Output should be either an empty square because the much larger circle covers the tile completely or a tile that has the result of the intersection of the circle and existing tile shape removed leaving what was left of the tile...

Research Link StackOverflow Thread

EDIT:

for (int i = 0; i < paint_textures.size(); i++) {

            if (!current_paint.equals(paint_textures.get(i))) {

                paint_regions.get(paint_textures.get(i)).subtract(new Area(current_draw_area.createTransformedArea(mouse_point)));

                for (int y = adjY - 100; y < adjY + current_draw_area.getBounds().height + 100; y += 100) {

                    for (int x = adjX - 100; x < adjX + current_draw_area.getBounds().width + 100; x += 100) {

                        try {

                            if (paint_tiles.get(paint_textures.get(i)).get(new Point(x, y)).intersects(new Rectangle(x, y, 100, 100))) {

                                Area a = (Area) paint_regions.get(paint_textures.get(i)).clone();
                                a.intersect(new Area(new Rectangle(x, y, 100, 100)));

                                Path2D.Double d = new Path2D.Double(a.getPathIterator(null).getWindingRule());
                                d.append(a.getPathIterator(null), false);//This Causes painting to be Jumpy...

                                paint_tiles.get(paint_textures.get(i)).replace(new Point(x, y), d);

                            }

                        } catch (NullPointerException e) {
                        }

                    }

                }
            }
        }
Community
  • 1
  • 1
StoneAgeCoder
  • 923
  • 1
  • 7
  • 13
  • 1
    Could you not use `Area` by constructing it around the original `Path2D` (`Area area = new Area(originalPath);`) and then using it to subtract the area you want, then create a new `Path2D` from it (`Path2D original = new Path2D.Double(area);`)? – MadProgrammer Jun 18 '14 at 02:02
  • @MadProgrammer I don't know if that is ideal or not. I am altering the Areas according to there types so it is multilayered. The reason I need to subtract is because where one area is added all of the following areas are subtracted from. How expensive is the conversion? – StoneAgeCoder Jun 18 '14 at 02:19
  • Not sure, you'd have to test it. Can't be any more expensive then what you're doing ;) – MadProgrammer Jun 18 '14 at 02:30
  • @MadProgrammer That is essentially what I am doing right now in a way, but still involves Area. I am not sure if Path2D would be faster or not, but right now my drawing is jumpy at the edited live above. – StoneAgeCoder Jun 18 '14 at 02:49
  • @MadProgrammer Never mind it may be the fairly large looping process that is being done. I just commented out the everything inside the if and it was still jumpy. – StoneAgeCoder Jun 18 '14 at 02:59

0 Answers0