Discussion:
[cairo] Length of bezier curve
Plugin Everything
2018-01-04 10:08:03 UTC
Permalink
Hi. I'm drawing a bezier curve and want to only stroke a portion of it, 50%
for example. So I'm using cairo_set_dash to do that, but I need to know the
length of the curve for that to work. Does anyone know how to calculate the
length of the bezier curve? Thank you.
Behdad Esfahbod
2018-01-04 15:49:07 UTC
Permalink
See:
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/misc/bezierTools.py#L142
Post by Plugin Everything
Hi. I'm drawing a bezier curve and want to only stroke a portion of it,
50% for example. So I'm using cairo_set_dash to do that, but I need to know
the length of the curve for that to work. Does anyone know how to calculate
the length of the bezier curve? Thank you.
--
cairo mailing list
https://lists.cairographics.org/mailman/listinfo/cairo
--
behdad
http://behdad.org/
Bill Spitzak
2018-01-04 19:44:57 UTC
Permalink
See also the function splitCubicAtT in the same code, this may be a
better approach.
Post by Behdad Esfahbod
https://github.com/fonttools/fonttools/blob/master/Lib/fontTools/misc/bezierTools.py#L142
Post by Plugin Everything
Hi. I'm drawing a bezier curve and want to only stroke a portion of it,
50% for example. So I'm using cairo_set_dash to do that, but I need to know
the length of the curve for that to work. Does anyone know how to calculate
the length of the bezier curve? Thank you.
--
cairo mailing list
https://lists.cairographics.org/mailman/listinfo/cairo
--
behdad
http://behdad.org/
--
cairo mailing list
https://lists.cairographics.org/mailman/listinfo/cairo
--
cairo mailing list
***@cairographics.org
https://lists.cair
c***@aol.com
2018-01-04 18:53:47 UTC
Permalink
Hi James,

If you have the points to your curve, then you can get the bezier points for each segment and draw each segment a different color. What kind of curve are you drawing?

This program has a couple of different cairo drawings that you can experiment with. You can change the color of a curve segment in one of the drawings to see how it looks.

Eric

https://github.com/cecashon/OrderedSetVelociRaptor/blob/master/Misc/cairo_drawings/fish1.c
Continue reading on narkive:
Loading...