0

我已经研究过使用 EVEN-ODD Winding 规则来在一个区域中创建孔。事情在论坛上,我能想出的只是一个 Path2D.Double() 在其自身附加一个洞。我想在已经存在的 Path2D 中创建一个整体,就像 Area 类具有 Area.subtract(new Shape()); 做。生无可恋。我知道 Path2D 有能力提高我的游戏性能。

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);

注意:输出应该是一个空的正方形,因为更大的圆圈完全覆盖了瓷砖,或者一个瓷砖的结果是圆圈相交和现有的瓷砖形状被移除,留下瓷砖的剩余部分......

研究链接 StackOverflow 线程

编辑:

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) {
                        }

                    }

                }
            }
        }
4

0 回答 0