"Restore Shape" tool for liquify

TLDR: This adds a brush type to liquify. It restores shape and you can select what to preserve.

image.png

Example scenario:

  • Create new image. Draw a rectangle. Enter transform tool in liquify mode. Use move as the tool.
  • Make brush huge, move the rectangle away in any direction. Thanks to the large brush shape it should stay mostly kinda intact.
  • Next, still in liquify, switch to rotate, rotate the rectangle by 90deg or whatever
  • Next use move tool again, small brush size, high strength/amount and mess around with the rectangle, distorting it into whatever random form.
  • Now your goal is to undo these previous small changes, so you could:
    • ...undo: sucks because it does not help you at all if the small changes you made are way further back and you want to keep larger changes you already made since
    • ...liquify erase brush: sucks because it just does what it says, which is not what you want. It moves points back to their original position
    • ...manually try to un-distort via fine "move" movements: lmao, good luck

There are some people that also want this apparently: https://krita-artists.org/t/relax-mode-in-liquify-tool-can-implement-req-as-well/186602/4

I have made these additions because I found no way to do this properly with things that area already in krita. I have searched on google etc, but all the answers made me roll my eyes.

What does it do exactly?

For all points in the cluster (within that dab)

  • compute centroid, get original angles between points
  • In one step:
    • restore relative angles
    • (if enabled) also restore original scale of the cluster
    • (if enabled) also restore original rotation of the cluster
    • (if enabled) also restore original stretch (meaning change in aspect ratio)
    • compute new centroid, shift points backwards so maintain centroid
    • maybe repeat

If all settings are "Preserve": It will only "un-crumple" the points to their original relative angles; trying to leave whatever other transformation you made (rotating the entire thing, scaling, ...) untouched. Its like "make this cluster recognizable again", which it will be once the relative angles have been restored enough.

If all settings are "restore": the result can be thought of as "these points, make them exactly as they were, just shifted to this new position"

Test Plan

Do the above, then use the new liquify brush mode named restore shape.

Video of it in action

Yes, I know this could have been accomplished with other transform tools, this is just an example of how it "undistorts" the left and right edges of the blue triangle

Formalities Checklist

  • I confirmed this builds.
  • I confirmed Krita ran and the relevant functions work.
  • I tested the relevant unit tests and can confirm they are not broken. (If not possible, don't hesitate to ask for help!)
  • I made sure my commits build individually and have good descriptions as per KDE guidelines.
  • I made sure my code conforms to the standards set in the HACKING file.
  • I can confirm the code is licensed and attributed appropriately, and that unattributed code is mine, as per KDE Licensing Policy.
  • Does the patch add a user-visible feature? If yes, is there a documentation MR ready for it at Krita Documentation Repository?

Reminder: the reviewer is responsible for merging the patch, this is to ensure at the least two people can build the patch. In case a patch breaks the build, both the author and the reviewer should be contacted to fix the build. If this is not possible, the commits shall be reverted, and a notification with the reasoning and any relevant logs shall be sent to the mailing list, kimageshop@kde.org.

Edited by Moritz Staudinger

Merge request reports

Loading