Skip to content

Refactor frame extension

What does the merge request do?

Closes #214 (closed)

This MR rewrites the Frame extensions. In it's current state, it's pretty useless. Following @Moini's suggestion in #214 (closed), the extension has now more capabilities that are inspired by https://inkscape.org/~RWE2/%E2%98%85frame+2.

Options have been added for

  • Rectangular and elliptical frame
  • Treat the selection as group (i.e. draw one big frame around all selected objects
  • Absolute and relative offset, both have their use cases; e.g. for a frame around a rectangle, absolute offset makes more sense (both margins are the same), but for objects with significantly different width than height, a relative offset might be preferable. Both offsets accept positive and negative values, and are given in user units and percentages, respectively.
  • The frame can be added above or below the objects, or the border above and the fill below - this is especially useful when insetting the frame and clipping the objects to the frame. -> Closes #214 (closed)

The extension also supports drawing frames around text elements, by querying Inkscape. (I know, it's slow, but it works!)

grafik

For example:

grafik

Implementation notes

  • I have found two situations where the extension gives incorrect results:
    • With "clip" activated, if applied to transformed elements, the clip is applied to the untransformed element (clip and frame are not aligned).
    • When a text element is selected in a transformed group - that's because the --query-id returns the visual bounding box and inkex computes the geometric one. -> requires fixing #119 (closed) for a real fix. I'm not going to tackle this in this MR.

Should I fix these or is this acceptable?

Also note that the result is interesting in transformed groups that have not only a translate transform. This is somewhat fixable, but I think the behavior is ok.

grafik

(The white ellipse is in a group with rotate(45), and the purple rectangle is an offset frame)

  • The function to query the bounding box should probably go into inkex, but that's up to discussion.

Summary for release notes

The Frame extension has been rewritten and now supports additional options, such as elliptical frames, offset frame and putting the fill below the object.

Checklist

  • Add unit tests (if applicable)
  • Changes to inkex/ are well documented
  • Clean merge request history
Edited by Jonathan Neuhauser

Merge request reports