How to offset a cubic bezier curve?

后端 未结 4 1533
感动是毒
感动是毒 2020-12-01 02:33

I\'m trying to create a \"parrallel\" bezier curve. In my attempts I\'ve gotten close but no cigar. I\'m trying to keep a solid 1px offset between the 2 curves (red,blue).

4条回答
  •  旧时难觅i
    2020-12-01 02:39

    It's not possible in general to represent the offset of a cubic Bezier curve as a cubic Bezier curve (specifically, this is problematic when you have cusps or radius of curvature close to the offset distance). However, you can approximate the offset to any level of accuracy.

    Try this:

    • Offset the Beziers in question (what you have already seems pretty decent)
    • Measure the difference between each original curve and corresponding offset curves. I'd try something like 10 samples and see if it works well.
    • For any offset that's outside of tolerance, subdivide (using the deCastlejau algorithm for Beziers) and iterate.

    I haven't implemented an offset (because the kernels I use already have one), but this seems like something to try.

提交回复
热议问题