路径描边算法(转换为三角形/四边形)或其他建议

发布于 2024-11-28 23:12:00 字数 363 浏览 2 评论 0原文

有谁知道将矢量路径转换为由三角形/四边形面组成的描边路径的好算法?最好采用圆线连接。

基本上,我试图绘制一条粗路径,其颜色基于随路径距离变化的值。我正在考虑将路径转换为三角形/四边形,并通过提供沿路径的距离作为一维纹理坐标来映射它,然后可以使用该坐标来检索三角形角处的颜色并进行插值。 关于如何做到这一点的任何其他建议,看起来不会很糟糕并且可以抗锯齿,我们将不胜感激。

目前,我正在使用 AGG 进行渲染,但我也许可以使用替代方案,前提是它没有太多依赖项。我想用于渲染的后端并不重要。虽然 AGG 可以绘制路径,但 VertexSource 接口不允许使用除 x/y 坐标之外的其他顶点信息。此外,当使用普通的 conv_lines 时,将我的颜色映射到光栅化器中看起来并不可行。

Does anyone know a good algorithm for converting a vector path into a stroked path that is composed of triangle/quad faces? Ideally with round line joins.

Basically I am trying to draw a thick path that whose colour is based upon a value that varies with the distance along the path. I'm thinking that converting the path to triangles/quads and texture mapping it by providing the distance along the path as a 1d texture coordinate that can then be used to retrieve the colours at the corners of the triangles and interpolate.
Any other suggestions on how to do this that won't look terrible and can be anti-aliased would be appreciated.

I'm using AGG for rendering, currently, but I could maybe use an alternative provided it doesn't have too many dependencies. I guess the back-end used for rendering doesn't really matter. Whilst AGG can stroke paths, the VertexSource interface does not allow for additional vertex information other than the x/y coordinates. Additionally getting my colour mapping into the rasterizer doesn't look feasible when using the normal conv_stroke.

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

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

发布评论

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

评论(2

欢你一世 2024-12-05 23:12:00

这是另一个很棒的资源,用于了解抚摸 a 的机制小路。

Here's another great resource for understanding the mechanics of stroking a path.

漫雪独思 2024-12-05 23:12:00

对于任何寻找解决方案的人来说,我发现这很有用:现实的 2D 绘图系统

因此,您可以有效地将正多边形与线进行卷积来生成网格。需要比 pdf 中概述的稍微复杂的算法才能输出三角形,但扩展它实际上并不太困难。

您还可以按照 agg::span_gouraud_rgba 的方式为 AGG 编写一个自定义跨度生成器,但它可以有效地进行纹理映射。

For anyone looking for a solution to this, I found this useful: A Realistic 2D Drawing System

So you can effectively convolve a regular polygon with the line to generate the mesh. Requires a slightly more complicated algorithm than outlined in the pdf in order to output triangles, but it's not actually too difficult to extend it.

You can also write a custom span generator for AGG along the lines of agg::span_gouraud_rgba but one that effectively does texture mapping instead.

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