# What is the mathematics behind inkscape's power stroke path effect interpolator_type and interpolator_beta attributes?

Inkscape has a feature called Power Stroke which is a form of path effect. When you apply it to a stroke you gain 3 control points that allow you to adjust the thickness of the stroke. (I have not yet figured out how to add more control points through the UI, but it can be done in the XML editor).

Inspecting the SVG reveals that the stroke gets turned into a fill with a path@d that specifies the outline, allowing the SVG file to be rendered by applications that know nothing of Power Stroke.

Applications that do understand Power Stroke will be looking for these attributes on the <path>:

   inkscape:path-effect="#path-effect881"
inkscape:original-d="m 109.59491,132.23789 c -19.148152,28.51854 -37.80734,35.62606 -46.969458,22.13393 -9.383889,-13.81871 -39.69277,-3.57313 -46.276359,5.34215 -16.01795169,21.691 17.695947,71.79071 39.993907,62.61593 17.000232,-6.99496 23.845432,-20.30176 23.845432,-20.30176"


The definition of the PowerStroke control points occurs inside the <defs>

<inkscape:path-effect
effect="powerstroke"
id="path-effect881"
is_visible="true"
offset_points="0.11606368,4.5282059 | 0.61857805,2.0941625 | 1.992627,6.538108 | 2.7945971,4.4492524"
sort_points="true"
interpolator_type="CubicBezierFit"
interpolator_beta="0.2"
start_linecap_type="round"
linejoin_type="bevel"
miter_limit="4"
end_linecap_type="butt" />


I have concluded that the @offset_points list can be interpreted as a list of t,r tuples, where t=0 is the first "major" control point in the path@d, and t=1 is the next. A segment that is a cubic bezier curve is traditionally interpreted as having 4 control points, but for the purpose of path effects, the first and last control points are what I have termed "major" control points, and are shared with the segments on either side.

What I do not yet understand is the @interpolator_type, likewise the @interpolator_beta. I assume this controls how you interpolate the radius you calculate between the different offset_points, but I'm not sure what exact formula to use. When I think Bezier, I think of Bezier curves, and how they only match up with their control points at the end of the segment. I think the _beta corresponds to the "smoothness" field in the UI.

If I wanted to calculate the Power Stroke radius at t=1.32, what formula would I use?

• FWIW, Inkscape is open source so you can just go and look at the source code for Power Stroke: lpe-powerstroke.cpp Commented Feb 26, 2021 at 22:45