Inkscape.org
Beyond the Basics Feature request: align objects by their midpoint or rotation center
  1. #1
    Ben Lincoln Ben Lincoln @benlincoln

    Let me begin by saying thank you to the dev(s) that added "Object midpoints" and "Object rotation centers" to the "Other points" section of the advanced snapping mode at some point in Inkscape's history. Those let me achieve the goal I came here to discuss, but I'd still like to ask for shortcut buttons in the Align and Distribute panel.

    When designing radially symmetric shapes, it's frequently necessary to center one shape within another based on the two shapes' center points. The "Center on vertical axis" and "Center on horizontal axis" buttons in Inkscape's Align and Distribute panel seem to operate based on the centers of the objects' bounding boxes. That works fine for circles, squares, and some other polygons with an even number of sides, but it produces incorrect results for polygons and polygrams (stars) with odd numbers of sides or points, and even some polygons with even numbers of sides (e.g. a duodecagon/12-sided polygon). Of course, it also produces incorrect results with more complex shapes, but it's easiest to demonstrate with polygons and polygrams: create a circle, create a triangle (or pentagon, pentagram, septagon, etc.), then try to center the triangle within the circle using the buttons in the Align and Distribute panel.

    As I mentioned at the beginning, Inkscape does have a way to do this via the snapping feature. Click the left-pointing arrow for snapping options, switch to advanced snapping (if not already enabled), enable "Object midpoints" or "Object rotation centers" in the "Other points" section, make sure any potentially problematic* options (e.g. "Bounding boxes" => "Centers") are disabled, then click and drag any necessary objects until the "Object rotation center to object rotation center" (or "Object midpoint to object midpoint") text appears and release. However, that requires quite a few manual steps, and is likely to require disabling some of the other snapping options that one might use for other kinds of object manipulation.

    I think it would be very useful to implement one of the following changes to reduce this to a single-click operation, and also allow it to be performed on a large number of objects at the same time:

    1. Add another dropdown similar to the "Relative to:" dropdown. Something like "Object centers:" with "Bounding boxes", "Rotation centers", and "Object midpoints" that would alter the behaviour of the existing "Center on vertical axis" and "Center on horizontal axis" buttons.
    2. Add four buttons to the Align and Distribute panel: "Center horizontally by rotation center", "Center vertically by rotation center", "Center horizontally by object midpoint", "Center vertically by object midpoint".

    I like the first option, because I think it would be a lot easier than trying to design icons that communicate the difference in centering modes. But regardless of the approach, nearly all of the code is already present because it's used for the snapping feature. I'd offer to submit a PR myself, but my poor C++ skills mean the cleanup discussion would probably be more effort for the existing devs than someone else adding it from scratch.

    It might even make sense to make the default mode either rotation centers or midpoints instead of bounding boxes, since e.g. the polygon/polygram tool (and I assume other features) already set the rotation center to the geometric center of the object when it's created.

    * "Problematic" here being shorthand for "anything that is likely to cause the snapping feature to bounce back and forth between two similar snapping points".

  2. #2
    inklinea inklinea @inklinea⛰️

    I've put in a request for this ( centre of mass ) you could reply and add to it.

    https://gitlab.com/inkscape/inbox/-/issues/9697

  3. #3
    Ben Lincoln Ben Lincoln @benlincoln

    Sorry, mistook the "finger pointing up" for thumbs-up, can't figure out a way to get rid of it.

    I'd suggest allowing either center of rotation or center of object, since center of rotation can be manually set on a per-object basis if Inkscape gets it incorrect somehow, versus always calculating the object's center.

Inkscape Inkscape.org Inkscape Forum Beyond the Basics Feature request: align objects by their midpoint or rotation center