视频合成 - 制作波浪、图案、渐变
我正在编写一个程序来生成一些狂野的视觉效果。到目前为止,我可以用随机的蓝色值绘制每个像素:
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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我以前也曾做过这样的把戏。 不幸的是,我没有代码:-/
您会对按位和整数算术运算符产生的效果感到惊讶:
抱歉,但我不记得确切的组合,所以
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:
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.
波通常使用三角函数(正弦/余弦)或近似它们的表格来完成。
您还可以通过一些简单的数学来制作一些很酷的水波纹。请参阅此处获取代码和在线演示。
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.