I'm writing a game, and I want an area of the screen to have a tiled paint drawn on it. Using a TexturePaint java supports texturing a Shape with a tiled texture, this is really simple and performs pretty well. However, I want my tiled texture to be rotated before drawing it as a fill to the shape - this is theoretically possible by subclassing TexturePaint and applying a transform, However, this performs really badly.
Does java in some way support doing this? If not, is there any reasn that subclassing texturePaint might perform really badly?
Your best off just simply rotating 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 be able to subclass TexturePaint without recieving a preformance drop, I can only assume that your rotation code is causing the drop.
I hope this helps.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With