低悬图形编程水果? [英] Low-hanging graphics programming fruits?
问题描述
我目前正在Java2D中开发基于瓦片的游戏,并且正在考虑添加一些便宜的眼镜糖。例如,实现一个简单的粒子系统(可能类似于 )用于爆炸和/或烟雾。
对于相对容易的编程效果,您是否有任何建议,而不需要绘制大量(或全部)新艺术作品?
上述效果的教程和代码示例也非常受欢迎!
- 我。
PS - 如果绝对必要,我可以切换到LWJGL / JOGL甚至Slick - 但我宁愿留在Java2D中。
BufferedImage
,可以使用 ConvolveOp
/api/java/awt/image/Kernel.htmlrel =nofollow noreferrer> Kernel
: BufferedImageOp op = new ConvolveOp(new Kernel(3,3,
new float [] {
1 / 9f,1 / 9f,1 / 9f ,
1 / 9f,1 / 9f,1 / 9f,
1 / 9f,1 / 9f,1 / 9f
}
));
BufferedImage resultImg = op.filter(originalImg,resultImage);
不太确定何时需要模糊效果,但它可能会派上用场。但我认为这是一个简单实施的低成果。
以下是关于卷积矩阵。它可以用来实现锐化,浮雕,边缘增强等效果。
I'm currently working on a tile-based game in Java2D, and I was thinking of adding some cheap eye candy.
For example, implementing a simple particle system (maybe something like this) for explosions and/or smoke.
Do you have any suggestion for relatively easy to program effects that wouldn't require drawing a lot (or at all) of new art?
Tutorials and code samples for said effects would also be most welcome!
-Ido.
PS - if absolutely necessary I could switch to something like LWJGL/JOGL or even Slick - but I rather stay with Java2D.
Implementing blurs and other image filtering effects are fairly simple to perform.
For example, to perform a blur on a BufferedImage
, one can use the ConvolveOp
with a convolution matrix specified in a Kernel
:
BufferedImageOp op = new ConvolveOp(new Kernel(3, 3,
new float[] {
1/9f, 1/9f, 1/9f,
1/9f, 1/9f, 1/9f,
1/9f, 1/9f, 1/9f
}
));
BufferedImage resultImg = op.filter(originalImg, resultImage);
Not quite sure when a blur effect is needed, but it may come in handy some time. But I'd say it's a low-hanging fruit for its ease of implementation.
Here's some information on convolution matrices. It can be used to implement effects such as sharpen, emboss, edge enhance as well.
这篇关于低悬图形编程水果?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!