0

我正在将 OpenGL 绘图代码转换为 SVG。OpenGL 的一个特性是,在绘制闭合线(或多边形)时,您可以为每个顶点指定颜色:

short vertices[100*3] = {100, 100, 100, 102, 102, 102, ....};
glVertexPointer(3, GL_SHORT, 0, vertices); // give vertices to OpenGL
char colors[100*3] = {255, 0, 0, 254, 0, 0,....};
glColorPointer(m_3, GL_UNSIGNED_BYTE, 0, pColors);// give color to OpenGL
glDrawArrays(GL_POLYGON, 0, 100);

这将使填充颜色根据与每个点的距离而变化。

在 SVG 中,我只能为多边形指定一种填充颜色:

<polygon points="0 524 0 509 5 509 5 524" stroke="#000000" fill="#453d3b" stroke-width="8.00000px"/>

有没有办法用 SVG 实现这种效果?

4

0 回答 0