路径笔划算法(转换为三角形/四边形)或其他建议 [英] Path stroke algorithm (convert to triangles/quads) or other suggestions

查看:139
本文介绍了路径笔划算法(转换为三角形/四边形)或其他建议的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有谁知道一个将矢量路径转换为由三角形/四边形面组成的描边路径的好算法吗?理想情况下,用圆线连接。基本上,我试图绘制一条厚厚的路径,其颜色基于一个随路径距离而变化的值。我正在考虑将路径转换为三角形/四边形和纹理,通过提供沿着路径的距离作为1d纹理坐标来进行映射,然后可以使用该纹理坐标来检索三角形边角处的颜色并进行插值。
如何做到这一点,不会看起来很糟糕,可以消除锯齿的任何其他建议,将不胜感激。



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

对于任何正在寻找解决方案的人对此,我发现这很有用:
https://keithp.com/~ keithp / talks / cairo2003.pdf



因此,您可以使用线条有效地卷积正多边形以生成网格。为了输出三角形,需要一个稍微复杂一点的算法,但实际上并不太难。



您也可以编写自定义span生成器对于AGG沿着agg :: span_gouraud_rgba的行,但有效地做纹理映射。


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.

解决方案

For anyone looking for a solution to this, I found this useful: https://keithp.com/~keithp/talks/cairo2003.pdf

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.

这篇关于路径笔划算法(转换为三角形/四边形)或其他建议的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆