Skip to content

Implement Curvilinear Perspective Assistant

Isaac Fleetwood requested to merge isaacfleetwood/krita:master into master


The Assistant tool contains many features for perspective including the Vanishing Point, 2 Point Perspective, Perspective (grid), etc. However, the current tools for curvilinear perspectives (in which parallel lines follow an arc to converge at 2 vanishing points) are lacking, with the only similar option being the Fish-Eye Point assistant. However, the Fish-Eye Point assistant uses ellipses instead of circular arcs, which, while potentially useful for other forms of perspective, is not useful for the types of 4, 5, and 6 point perspectives that I wish to do.


I have implemented a general Curvilinear Perspective assistant that allows one to select two points to create guidelines that follow circular arcs to converge at two vanishing points. Based on how many of these assistants a person uses, and how many normal vanishing points a person uses, they can create 4, 5, and 6 point perspective in a mathematically accurate way.

Separate 4-point, 5-point, and 6-point tools could have been an option. However, I chose for a more general purpose tool that can be used for those features, in order to avoid clutter, both in guidelines on the canvas, and options in the assistant tool. If desired though, future assistants specifically for these types of perspective could be made to make this feature more easily accessible.

This assistant was created by forking FishEyePointAssistant and modifying it to use 2 handles and render new visuals, adding it to all appropriate assistant functions that change behavior based on the selected assistant, and registering the factory inside of the appropriate class.

Creating a new assistant :CurvilinearPrespective

4 Point Perspective (using 1 Curvilinear Perspective assistant):Screenshot_from_2023-10-14_10-39-56

5 Point Perspective (using 2 Curvilinear Perspective assistants):Screenshot_from_2023-10-14_12-07-19

Test Plan

  • Verify Curvilinear Perspective is available as new assistant in the Assistant Tool options.
  • Verify the tool allows placement of 2 handles that, when placed, render series of circular arcs containing the two vanishing points.
  • Verify that handles can be moved and snapped, with the guide adjusting in realtime.
  • Verify that an extra guideline is created in real time based on mouse position while drawing tools are selected.
  • Verify mouse position is correctly reported and the associated guideline rendered properly in a non-Linux environment.
  • Verify that any assistants are saved whenever the file is saved by saving the file and reopening it.
  • Verify that brush "Snap to Assistants" works whenever enabled, and that the preview lines are correct.
  • Verify that "Show Painting Assistants" and "Show Assistant Previews" properly toggle the associated guide lines.

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 do not believe there are any relevant unit tests for testing all assistants (there are a couple for individual assistants), but I can confirm no unit tests failed that did not fail before the change (Some did fail both before and after).
  • 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,

Edited by Isaac Fleetwood

Merge request reports