Closed Brooooooklyn closed 2 years ago
Nice! PathOps is particularly important for font processing and can help us convert the Fill rule of SVG.
当前 Skia 官方的 pathkit 没有导出 asWinding()
函数,希望也可以增加这个 API。它在字体处理中非常有用,可以把 fill-rule
由 evenodd
转换为 nonzero
。
这个 .NET 库中有类似的导出:https://github.com/mono/SkiaSharp/issues/840
asWinding() 完成度不如 skia-pathops 现在还无法完全摆脱 python 的代码
抱歉,是我搞错了。
asWinding() 目前只能处理没有交叉点的 path ,这是一个已知问题,不能算bug,起码不是下游skr canvas的bug。
Set the result with fill type winding to area equivalent to path. Returns true if successful. Does not detect if path contains contours which contain self-crossings or cross other contours; in these cases, may return true even though result does not fill same area as path. Returns true if operation was able to produce a result; otherwise, result is unmodified. The result may be the input.
Demo:
https://codesandbox.io/s/github/OpenGG/evenodd-fix-winding?file=/src/App.vue
@OpenGG 印象中,我记得 skia-pathops 对于 asWinding()
做过一些特殊处理
https://codesandbox.io/s/github/OpenGG/evenodd-fix-winding?file=/src/App.vue
你的示例中,视觉上看起来 skia-canvas 和 skr-canvas 的结果一样?
@yisibl 是的,skia-canvas 和 skr-canvas 都直接使用了 skia 的 asWinding() ,都不能处理交叉点。 skia-pathops 在 python 里有一个特殊处理,所以可以得到正确结果。
https://skia.org/docs/user/modules/pathkit/
/cc @yisibl