对基于数学的图像进行编程以用于高分辨率艺术品

发布于 2024-08-14 00:09:40 字数 1431 浏览 9 评论 0原文

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

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

发布评论

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

评论(7

小忆控 2024-08-21 00:09:40

创建此类图像的最佳方法是学习编写 PostScript。它是一种简洁的语言,易于学习,一旦熟悉了它就会非常强大。

Bill Casselman 的手册是迄今为止高质量数学插图的最佳参考。

The best way to create images like these is to learn to write PostScript. It's a clean language, easy to learn, and quite powerful once you know it well.

Bill Casselman's manuals are by far the best reference for high quality mathematical illustration.

睫毛溺水了 2024-08-21 00:09:40

使用矢量图像格式,例如 SVG。这将完美地扩展到任何分辨率。

Inkscape 是创建这些内容的绝佳工具。

拥有矢量图像格式后,根据您选择的语言,可以有多种在编程语言中使用它的选项。

例如 -

Use a vector image format like SVG. This will scale perfectly to any resolution.

Inkscape is a great tool for creating these.

Once you have a vector image format, there are many options for using it in programming languages, depending on your language of choice.

For example -

海风掠过北极光 2024-08-21 00:09:40

我不知道这些图像是如何创建的,我猜它们是从书上扫描的,但是,在我的分形工作中,我倾向于从使用 标签开始,主要是这样我可以改变元素的大小并看到它绘制了更多迭代,这样我就可以获得最高分辨率。

像 SVG 这样的东西的问题在于,你需要选择一个分辨率然后创建它,它会很好地放大和缩小,但如果你以一种分辨率开发它,那么你就需要使用更高分辨率来演示,您可能会看到比您想要的更多的差距。

如果你只想这样做并将其保存为静态图像,那么任何 GUI 都可以工作,因为你当时保存的是 GIF,但如果你想要它,例如,在网页上,并让它看起来一样好因为它可以在该浏览器上运行,那么您可能需要考虑使用 javascript。

数学部分并不难,因此一旦推导出所需的递归算法,绘制图像就相当容易。我倾向于进行下一次迭代,直到尺寸低于阈值,例如,半径 < 。 3、然后退出。

I don't know how those images were created, I would guess they were scanned from a book, but, in my work with fractals, I tend to start with just using the <canvas> tag, mainly so that I can change the size of the element and see it drawn more iterations, so I can get the highest resolution.

That is the problem with something like SVG is that you would need to pick a resolution and then create it, and it will scale well up and down, but if you developed it at one resolution, then you go to a higher resolution to demo, you may see more gaps than you would like.

If you want to just do it and save it as a static image then any GUI will work, as you are saving a GIF at that point, but if you want it, for example, on a web page, and have it look as good as it can on that browser then you may want to look at using javascript.

The math part isn't hard, and so drawing the image is fairly easy, once you derive the recursive algorithm that is needed. I tend to go to the next iteration until the size is below a threshold, for example, a radius of < 3, then it exits.

把时间冻结 2024-08-21 00:09:40

好吧,#2 将是一场圣战,所以我将讨论#1。 :)

这种性质的图像的关键是递归。基本上,它们是以受控的方式一遍又一遍地重复相同的图像,以获得有趣的结果。以生命之花为例。您重复中心花瓣六次(制作花瓣的方法取决于您)。然后,使用花瓣尖端作为中心并重叠其中一个花瓣,再创建六朵花。然后你递归地向外移动。几个“回合”后,您停下来画出包含的圆。基本上,recussion 模拟了手动操作时所需的冲压、移动和旋转。

当我尝试这些东西时,我总是发现实验是获得很酷的新东西的最好方法。当然,这可能只是我缺乏想象力。 :)

我知道我在这个答案中数学不是很重,但这取决于你和实验。请记住,COS 和 SIN 是您的朋友,并且循环中有 360 度(或 2pi 弧度,具体取决于您的数学包)。

编辑:为“花”添加一些数学运算,以

(Xo, Yo) 中心和 r 花半径开始...

花瓣的尖端(P0、P1 等)由...确定,

X = Xo + (sin((n * pi)/3 + (pi / 6)) * r)
Y = Yo - (cos((n * pi)/3 + (pi / 6)) * r)

其中 n 是花瓣数 (0..5)

一旦计算出花瓣尖端,只需绘制花瓣,然后在尖端开始一朵新花。您还可以设置一个边界圆,以便不会绘制该圆之外的任何点。

Well, #2 is going to be kind of a holy war so I'll address #1. :)

The key to images of this nature is recursion. Basically they are the same image repeated over and over in a controlled way to get an intersting result. Take the flower of life for example. You repeat the center petal six times (the method to do the petals is up to you). Then you create six more flowers using the petals tip as the center and overlapping one of the petals. You then recursively move outward. After a few "rounds" you stop and draw the containing circle. Basically the recusion simulates the stamp, move and rotate that would be required if you were doing it by hand.

When I have played around with these kinds of things I have always found that experimentation is the best way to get cool new things. Of course that could be just my lack of imagination. :)

I know I am not very math heavy in this answer but that is up to you and experimentation. Just remember that COS and SIN are your friends and there are 360 degrees in a cricle (or 2pi radians depending on your math package).

EDIT: Adding some math for the "Flower"

Starting with a center of (Xo, Yo) and a flower radius of r...

The tips of the petals (P0, P1, etc) are determined by...

X = Xo + (sin((n * pi)/3 + (pi / 6)) * r)
Y = Yo - (cos((n * pi)/3 + (pi / 6)) * r)

where n is the petal number (0..5)

Once you compute a petal tip, just draw the petal and then start a new flower at the tip. You would also set a bounding circle so that any point outside that circle would not be drawn.

无语# 2024-08-21 00:09:40

我会尝试用 Java 中的 iText 创建 PDF。 PDF 支持矢量图形,因此它应该可以毫无问题地缩放。我不知道当您拥有大量图形元素时,iText 的性能扩展效果如何。

I would try to create a PDF with iText in Java. PDF supports vector graphics, so it should scale without problems. I don't know how well iText scales w.r.t. performance when you have a really big number of graphic elements.

滴情不沾 2024-08-21 00:09:40

A1。您可能想看看海龟图形、l-系统、迭代函数系统、空间填充曲线,以及可能还有许多我不熟悉或尚未想到的其他方法。

A2。您可以使用您建议的任何语言对其中任何一个进行编程。我喜欢 Mathematica,但我知道并不是每个人都有它的副本,而我有一个副本,因为我从事数字运算工作,并且可以用它来制作漂亮的图片。但是,Processing 是免费的,旨在对艺术家友好,对您来说可能是一个更好的起点。 Mathematica 和Processing 都可以立即进行图形处理,无需调用外部库(或担心使用哪些库)。

而且,虽然我同意每个人都说矢量是要走的路,但不要忘记最后的制作步骤,在纸上或屏幕上,是渲染,所以要考虑一下如何完成。例如,这可能会引导您选择 Postscript 或 PDF 作为输出格式。

玩得开心

马克

A1. You might want to look at turtle-graphics, l-systems, iterated function systems, space filling curves, and probably a lot of other approaches I'm not familiar with or haven't thought of yet.

A2. You can program any of these with any of the languages you suggest. I like Mathematica, but I know that not everyone has a copy of it and I have a copy 'cos I work in number-crunching and get to play with it for making pretty pictures. But Processing, which is free, was designed to be artist-friendly and might be a better starting point for you. Both Mathematica and Processing do the graphics right there and then, no calls to external libraries (or worrying which ones to use).

And, while I agree with everyone who says that vectors are the way to go, don't forget that the final productions step, onto paper or screen, is rendering so give some thought to how that will be done. This might, for example, lead you to Postscript or PDF for an output format.

Have fun

Mark

世界等同你 2024-08-21 00:09:40

嗯,我曾经用指南针画生命之花,当时在初中……实际上很简单……但我认为这不是您正在寻找的答案。

基本上,它包括从每个点绘制一个相同半径的圆,直到遇到大圆(极限)。

Well, I used to draw flowers of life with a compass, back then in junior school ... very simple actually ... but I don't think that's the answer you're looking for.

Basically it consists of drawing a circle of the same radius, from every point, until you encounter the big circle (limit).

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