Inkscape.org
Creating New Extensions Scale, rotate, transform around an anchor.
  1. #1
    DrQt DrQt @DrQt

    I have a series of add_scale, add_rotate, add_transforms working.

    Rotate has a center anchor, but scale seems to default to 0,0 of the art board.

    Is there a way to move that around?

    Currently I’m working with an image that can be scaled with its own x/y,

    If I was working with shapes, do I need to move them to 0,0 (or my anchor point) first and then move them back?  I’m inclined to handle images in the same way so everything is consistent but I’m not sure what to do.

    Any ideas?

     

     

  2. #2
    DrQt DrQt @DrQt
    *

    Here is how I am currently rotating, translating, and scaling around an anchor. 
    It's pretty unwieldy.

    Am I approaching this wrong? 
    Everything is dependent on (0,0) for scaling.

    I transforming an image and matching mask shapes. 
    Part of the problem is I have a dictionary of points I want to keep in correspondence with their path representation, but leaning on the simplicity of the built in path transforms.

    The node sequence in the path string doesn't change right?  Or does, add_rotate alter the sequence as well?  Should I always have a group layer going to avoid losing that correspondence?

    Is there point based scale anchoring with groups?

     

    img         = image_load(parentnode,img_path)
    
    tgt_sqr     = [[0,0],[500,500]]
    
    tgt_len     = tgt_sqr[1][0] - tgt_sqr[0][0]
    scale       = tgt_len / (side["length"])
    tr          = inkex.Transform()
    tr.add_scale(scale)
    img.transform = tr * img.transform
    
    tgt_rot     = 90 - side["angle"]
    p1_x        = side["x"][0]
    p1_y        = side["x"][1]
    tr          = inkex.Transform()
    tr.add_rotate(tgt_rot, p1_x, p1_y)
    img.transform = tr * img.transform
    
    trn_x       = tgt_sqr[0][0] - p1_x * scale
    trn_y       = tgt_sqr[0][1] - p1_y * scale 
    tr          = inkex.Transform()						
    tr.add_translate(trn_x, trn_y)
    img.transform = tr * img.transform

     

Inkscape Inkscape.org Inkscape Forum Creating New Extensions Scale, rotate, transform around an anchor.