如何画云彩?
我需要一种算法来绘制云或类似云的形状。显然,我不希望它们都相似。
我应该使用什么来生成相关的 X,Y 坐标系列来绘制云彩?
我将在 SVG 或 Canvas 中实现它
I need an algorithm to paint clouds, or cloud like shapes. Obviously, I wouldn't want them all to be similar.
What should I use to generate the relevant series of X,Y coordinates to paint the clouds?
I am going to implement this either in SVG or Canvas
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(7)
这取决于您想要什么样的云。您可以尝试一下深受游戏开发者欢迎的 Perlin 噪音。
It depends on exactly what kind of clouds you're going for. You can try Perlin noise which is quite popular with game developers.
您可以使用 SVG feTurbulence 滤镜基元生成 Perlin 噪声,该噪声可用于创建云状纹理。
一些帮助和示例:
Inkscape 矢量图形编辑器有大量预定义的 svg 滤镜,请参阅此处 一个示例,仅使用一些其中一些文字。 “噪声填充”使用 feTurbulence,并且可能很容易调整。 Inkscape 还有一个 GUI,用于调整每个滤镜的参数,选择任何形状,然后在菜单中选择“滤镜 > 滤镜编辑器...”。
You can use the SVG feTurbulence filter primitive to generate Perlin noise, which can be used to create cloud-like textures.
Some help and examples:
The Inkscape vector graphics editor also has a big collection of predefined svg filters, see here for an example using just a few of them on some text. The "noise fill" one is using feTurbulence, and is probably quite easy to tweak. Inkscape also has a GUI for tweaking the parameters of each filter, select any shape, then select "Filter > Filter Editor..." in the menus.
为了给你的树木朋友,画许多快乐的小意外。
我推荐画布——你可以用画笔疯狂!
我祝愿你绘画愉快,愿上帝保佑我的朋友。
To give your trees friends, paint many happy little accidents.
I recommend canvas - you can get crazy with the brush!
I'd like to wish you happy painting, and God bless my friend.
这是使用 silverlight 完成的柏林噪声示例: http ://kodierer.blogspot.com/2009/05/oscar-algorithm-silverlight-real-time.html
它可能是您可以使用和/或适应的东西。
here is an example of Perlin noise done with silverlight: http://kodierer.blogspot.com/2009/05/oscar-algorithm-silverlight-real-time.html
it's probably something you can use and/or adapt.
如果在画布上实现,并且您想要蓬松的云形状而不是噪声类型,我会说绘制一个随机长度的矩形,然后首先在侧面添加不同大小的圆圈,然后在顶部添加不同大小的圆圈以获得云效果。您必须进行一些数学运算,以确保矩形下方没有出现云,并且矩形的顶部没有任何直线部分。但在画布上实现应该不难。
If implementing in canvas and you want the puffy cloud shape not the noise kind, I would say draw a rectangle of some random length then add circles of varying sizes first to the sides then to the top to get the cloud effect. You would have to do some math to make sure the clouds did not show below the rectangle and that the top of the rectangle did not have any straight sections. But it shouldn't be to hard to implement in canvas.
这段代码用一系列颜色制作了一堆圆圈,也许它会帮助你处理云
this code makes a bunch of circles in an array of colors maybe it will help you with the clouds
生成一组气泡(圆形或水平椭圆形),并合并每个云的形状。
Generate a cluster of bubbles (circles or horizontal ellipses) and take the union of the shapes for each cloud.