Tiled paint

I am writing a game, and I want tiled paint to be painted on an area of ​​the screen. Using TexturePaint java supports Shape texturing with a tiled texture, it is very simple and works very well. However, I want my mosaic texture to be rotated before drawing it as a form fill - this is theoretically possible by subclassing TexturePaint and applying a transform. However, this is doing very poorly.

Does java support this? If not, is there any effect that subclassing texturePaint can work very poorly?

+3
source share
1 answer

It's best to just rotate the BufferedImage before throwing it at TexturePaint.

AffineTransform texture = new AffineTransform();
texture.rotate(radians, bufferedImage.getWidth()/2, bufferedImage.getHeight()/2);

AffineTransformOp op = new AffineTransformOp(texture, AffineTransformOp.TYPE_BILINEAR);
bufferedImage = op.filter(bufferedImage, null);

You should have a subclass of TexturePaint without getting a personnel reduction, I can only assume that your rotation code causes a drop.

Hope this helps.

+1
source

Source: https://habr.com/ru/post/1733228/


All Articles