低悬图形编程水果? [英] Low-hanging graphics programming fruits?

查看:157
本文介绍了低悬图形编程水果?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆