You have to define the "center" of the stroke Is it the center of the bounding box? The center of mass/centroid? or something else? Once you have determined that, you compute the center for the before/after/strokes, compute the delta vector, and shift the stroke accordingly.
Note: the API to translate a stroke (stroke:translate() or its PDB equivalent) only shifts an integer amount of pixels, which makes it unusable in most cases. So you just construct a new stroke by adding the corresponding delta to all coordinates (anchors and tangents). A nice trick is to use a "cycle" generator:
But your 2nd image makes me think that you don't want a scaled stroke, but the stroke which is "parallel" to the outer one, which is a different thing. If you tell me what you are trying to do I can find a way to do it differently. If you are on 2.10 there is however an indirect way to have Gimp create that path for you.
Note: the API to translate a stroke (stroke:translate() or its PDB equivalent) only shifts an integer amount of pixels, which makes it unusable in most cases. So you just construct a new stroke by adding the corresponding delta to all coordinates (anchors and tangents). A nice trick is to use a "cycle" generator:
Code:
offsets=itertools.cycle([translateX,translateY])
sourceCoords,closed=sourceStroke.points
translatedCoords=[coord+next(offsets) for coord in sourceCoords]
translatedStroke = gimp.VectorsBezierStroke(targetPath,translatedCoords,closed)
But your 2nd image makes me think that you don't want a scaled stroke, but the stroke which is "parallel" to the outer one, which is a different thing. If you tell me what you are trying to do I can find a way to do it differently. If you are on 2.10 there is however an indirect way to have Gimp create that path for you.