渲染抗锯齿螺旋
我已经看过这个使用php和GD的示例来分段- 渲染带有小圆弧的螺旋。我想做的是渲染一个在数学上尽可能准确的螺旋近似值。
Inkscape 有一个看起来不错的 螺旋工具,但我想以编程方式生成螺旋(最好是Python)。
我还没有找到任何原生支持螺旋形状的绘图库(例如 Cairo)。如果想要渲染完美的抗锯齿螺旋,最好的方法是在画布上逐像素迭代,确定每个像素是否位于数学定义的螺旋臂区域(有限厚度)内?在这种情况下,还必须从头开始实现抗锯齿逻辑。您是否会对位于每个像素框内的曲线部分进行积分,然后将填充区域与空白区域的比率转换为 alpha 值?
在这种情况下,渲染质量比渲染时间更重要。然而,在我看来,评估每个像素的积分效率相当低。
更新:我相信我应该问的问题是这个(雅虎问答已失败)。
I have looked at this example using php and GD to piecewise-render a spiral with small arcs. What I would like to do is render an approximation to a spiral that is as mathematically accurate as possible.
Inkscape has a spiral tool that looks pretty good, but I would like to do the spiral generation programmatically (preferably in Python).
I haven't found any drawing libraries (e.g. Cairo) that natively support spiral shapes. If one wanted to render a perfect antialiased spiral, would the best way be to just iterate pixel-by pixel over a canvas, determining whether each pixel lies within a mathematically-defined spiral arm region (of finite thickness)? In that case, one would also have to implement anti-aliasing logic from scratch. Would you integrate the portion of the curve that lies within each pixel box, then convert the ratio of filled to empty area to an alpha value?
In this instance the quality of the rendering is more important than the rendering time. However, evaluating an integral at each pixel strikes me as pretty inefficient.
Update: I believe the question I should be asking is this one (for which Yahoo Answers has failed).
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
绘制曲线(样条线?)并生成大量控制点不是更容易吗?就像这样,您可以选择现有的抗锯齿引擎。
[编辑]:对此的第一个近似(使用 Tcl/Tk 完成,但代码应该很容易转换)给了我这样的结果:
我没有做出任何努力来有效地使用控制点。
Wouldn't it be easier to draw a curve (spline?) and just generate plenty of control points? Like that you'd pick up an existing antialiasing engine.
[EDIT]: A first approximation to this (done with Tcl/Tk, but the code should be easy to convert) gives me this:
I've not made any effort to be efficient in my use of control points.
不,这是一个非常不寻常的功能;直到最近,螺旋绘画才开始流行。
Inkscape 为此使用的代码是 Spiro。它主要是Python,并且可以使用Cairo来渲染螺旋线近似的贝塞尔曲线。
是的,确实如此。
No, it's quite an unusual feature; it's only very recently that drawing with spirals has become popular.
The code Inkscape uses for this is Spiro. It's mostly Python, and can use Cairo to render the beziers that the spirals are approximated into.
Yes, indeed.