视频合成 - 制作波浪、图案、渐变

发布于 2024-08-29 10:59:54 字数 299 浏览 6 评论 0原文

我正在编写一个程序来生成一些狂野的视觉效果。到目前为止,我可以用随机的蓝色值绘制每个像素:

for (y = 0; y < YMAX; y++) {
    for (x = 0; x < XMAX; x++) {
        b = rand() % 255;
        setPixelColor(x,y,r,g,b);
    }
}

我想做的不仅仅是制造蓝色噪音,但我不知道从哪里开始(谷歌今天没有给我太多帮助),所以它会如果您可以分享您对该主题的了解或一些相关资源的链接,那就太好了。

I'm writing a program to generate some wild visuals. So far I can paint each pixel with a random blue value:

for (y = 0; y < YMAX; y++) {
    for (x = 0; x < XMAX; x++) {
        b = rand() % 255;
        setPixelColor(x,y,r,g,b);
    }
}

I'd like to do more than just make blue noise, but I'm not sure where to start (Google isn't helping me much today), so it would be great if you could share anything you know on the subject or some links to related resources.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

自在安然 2024-09-05 10:59:54

我以前也曾做过这样的把戏。 不幸的是,我没有代码:-/

您会对按位和整数算术运算符产生的效果感到惊讶:

FRAME_ITERATION++;
for (y = 0; y < YMAX; y++) {
    for (x = 0; x < XMAX; x++) {
        b = (x | y) % FRAME_ITERATION;
        setPixelColor(x,y,r,g,b);
    }
}

抱歉,但我不记得确切的组合,所以b = (x | y) % FRAME_ITERATION;
实际上可能没有什么美丽的。但是,您可以尝试自己的组合。

不管怎样,使用上面这样的代码,你可以产生奇怪的图案,甚至像水一样的效果。

I used to do such kind of tricks in the past. Unfortunately, I don't have the code :-/

You'll be amazed of what effects bitwise and integer arithmetic operators can produce:

FRAME_ITERATION++;
for (y = 0; y < YMAX; y++) {
    for (x = 0; x < XMAX; x++) {
        b = (x | y) % FRAME_ITERATION;
        setPixelColor(x,y,r,g,b);
    }
}

Sorry but I don't remember the exact combinations, so b = (x | y) % FRAME_ITERATION;
might actually render nothing beautiful. But, you can try your own combos.

Anyway, with code like the above, you can produce weird patterns and even water-like effects.

乖不如嘢 2024-09-05 10:59:54

波通常使用三角函数(正弦/余弦)或近似它们的表格来完成。

您还可以通过一些简单的数学来制作一些很酷的水波纹。请参阅此处获取代码和在线演示。

Waves are usually done with trig functions (sin/cos) or tables that approximate them.

You can also do some cool water ripples with some simple math. See here for code and an online demo.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文