Skip to content

why is "moveto" actually "moveby" #91

@Knochi

Description

@Knochi

Hi,

I'm trying to open a svg file as a template and position objects programmatically.

SVGTest

I expected a new file with the rectangle and the circle but not the triangle (that worked), where circle and rectangle are placed at the same coordinate in the top left corner (that didn't work).

instead, when looking to the resulting svg i can see that elements get the "translate()" transformation, which is move by 20 to the right and 20 to bottom.

import svgutils.transform as sg
from svgutils.compose import Unit
import sys


ovWdth = Unit('1080px')
ovHght = Unit('768px')

fig = sg.SVGFigure(ovWdth,ovHght) 

#load template
tmpl = sg.fromfile('SVGTest.svg')


#get objects
boxObj = tmpl.find_id('rect846')
circObj = tmpl.find_id('path1076')

print(boxObj)

#move objects
boxObj.moveto(20,20)
circObj.moveto(20,20)

#append to figure
fig.append([boxObj, circObj])

#save figure
fig.save('SVGTest_Output.svg')

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions