开发者

Java tiled paint

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 texturePain开发者_如何转开发t 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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜