antvis / util

utility library for AntV products.
MIT License
74 stars 28 forks source link

segmentArcFactory 分段过多导致计算耗时 #92

Open xiaoiver opened 2 years ago

xiaoiver commented 2 years ago

Path 部分有两点需要优化:

// 仅计算包围盒
const { x, y, width, height } = getPathBBoxTotalLength(absolutePath, { bbox: true, length: false });

// 计算时减少采样数,牺牲精度提升性能
const { x, y, width, height } = getPathBBoxTotalLength(absolutePath, { bbox: true, length: false, sampleSize: 10 });

另外需要性能测试。

xiaoiver commented 2 years ago

在计算 Arc 长度 / 包围盒时,使用 10 段会造成结果精度差很多,暂时使用 30。

目前使用的分段方法似乎并不高效,需要对比下其他方式,例如: https://github.com/mondeja/svg-path-bbox