动态壁纸水波纹效果壁纸、效果、动态、水波纹

2023-09-12 11:03:44 作者:待你长发及腰为你剪掉可好

我工作的一个活的壁纸是纳入了触摸屏幕的一些水波纹效果,但我有点卡住了。

I'm working on a live wallpaper that incorporates some water ripple effects on touching the screen but I'm a little stuck.

它会更好,通过它们来创建多个图像和循环创建一个涟漪动画或将是更好扭曲位图位之前,我把它在画布上的?

Would it be better to create multiple images and loop through them to create a ripple animation or would it be better to distort the bitmap a bit before I place it on the canvas?

这是通过OpenGL的做了一个非常漂亮的波纹效果的视频。

This is a video of a very nice ripple effect done through OpenGL.

我没有任何经验,但用OpenGL,并想知道如果它仍然可以创建的动态壁纸二维水效果?

I don't have any experience yet with OpenGL and was wondering if it is still possible to create a 2D water effect on the live wallpaper?

推荐答案

我想在Android中实现逼真的连锁反应了,所以将分享我的经验:

I wanted to implemented a realistic ripple effect in Android too, so will share my experience:

作为一个参考实现我拍了尼尔·沃利斯的Java算法中谢尔盖的Chikuyonok JavaScript的端口。这里有一个游乐场,在这里您可以用原来的JS code实验: http://jsfiddle.net/esteewhy/5Ht3b/6/

As a reference implementation i took Sergey's Chikuyonok JavaScript port of Neil Wallis Java algo. Here's a playground where you can experiment with original JS code: http://jsfiddle.net/esteewhy/5Ht3b/6/

起初,我已经移植JS code到Java才知道,有没有办法挤1个多FPS我的华为U8100的硬件。 (这里是几个类似的尝试在网络上的唯一结论是:他们是可笑的慢)

At first, i've ported JS code to Java only to realize that there's no way to squeeze more than 1 fps on my Huawei U8100 hardware. (There're several similar attempts on the net with the only conclusion: they're ridiculously slow).

顺便说一句,这太答案是非常有用的,以了解如何为code在Android中的交互式图形基本的了解: HTTP: //stackoverflow.com/a/4946893/35438 。我已经从那里借来的FPS计数器。

BTW, this SO answer was quite useful to get basic understanding of how to code an interactive graphics in Android: http://stackoverflow.com/a/4946893/35438. I've borrowed fps counter from there.

然后我决定尝试的Andr​​oid NDK重新实现原来的算法中的纯C(与它在10+年我第一次遇到!)。尽管NDK的文档是有些混乱(尤其是需求和prerequisites),这一切工作就像一个魅力,所以我能够实现高达每秒30帧 - 它可能不会太IM pressive,但仍,彻底改善了Java的code。

Then i decided to try Android NDK to reimplement original algo in pure C (my first encounter with it in 10+ yrs!). Despite NDK's docs being somewhat confusing (especially as to requirements and prerequisites), it all worked like a charm, so i was able to achieve up to 30 fps -- it might not be too impressive, but still, a radical improvement over Java code.

最后,我已经把我所有的作品在网上: https://github.com/esteewhy/whater ,所以感觉自由与发挥。它包含:

Finally, i've put all my work online: https://github.com/esteewhy/whater , so feel free to play with that. It contains:

在互动弹跳球code以上(仅供参考)提到的。 在水波纹的Java接口(慢的像地狱!) 在水波纹C实现(需要NDK编译和JDK创建的.h文件)。

(该项目是不是干净,即:所有的二进制文件都在那里,所以可以尝试运行原样即使没有NDK)

(The project is not "clean", i.e.: all binaries are there, so can try to run it "as is" even without NDK.)