Skip to content

Add pixel grid alignment option to the pattern generator

This mr has 2 parts:

  1. It changes the pattern generator transformations ui to make it more similar to other dialogs and also more compact.
  2. It adds a new option to align the transformed pattern corners to the pixel grid.
    • This is similar to what I made in the screentone generator.
    • It was requested by a user that uses the pattern generator in combination with the halftone filter to make manga style gradients for comics.
    • For the pattern generator it seems less useful than for the screentone generator, although it can prevent moire patterns in some transformation combinations.
    • The way it works is as follows (as in the screentone generator):
      1. First a transform T is created using the user defined parameters (scale, rotation, etc.).
      2. The top-left corner of the pattern is at (0, 0). The top-right corner and the bottom-left one are transformed by T.
      3. The transformed points are aligned to the pixel grid.
      4. The transform A that maps the aligned transformed pattern corners to the original un-transformed ones is computed.
      5. A is an inverse transform, so the final transform is obtained by inverting A.
    • This option is useful for small patterns and in the case where the pattern is scaled down, when moire patterns appear.
    • The alignment ensures that the pattern repetitions look the same.
    • The alignment reduces the number of possible transformations, but the result is as close as possible to the un-aligned one.

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.

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.

Merge request reports