Hacking:WarpTool/UI design info

From GIMP Developer Wiki
Revision as of 20:28, 2 June 2011 by BatO (Talk | contribs)

Jump to: navigation, search

Idea and background

A plugin named iWarp (http://docs.gimp.org/2.6/en/plug-in-iwarp.html) already exists in Gimp, but suffer from different troubles (small preview, uneasy manipulation). This year’s Google Summer of Code have a project to implement this behavior as a real live on-canvas tool in Gimp. This project is taken by Michael Muré (batolettre@gmail.com, irc: Bat`O on #gimp@irc.gnome.org).

Basically, this would allow users to deform an image by a series of cursor action on it. This can be seen as a sort of sculpt. See for example the case where user can move pixel with a stroke of mouse. Others behavior can also be implemented, see below.

A quick technical sneak peek

This tool will be a complete rewrite, no parts will be taken from the plugin. The tool will works with Gegl. The plugin can be seen as a proof of concept.

Technically, this tool will work in two steps:

  1. a series of tools, one by behavior, act on a image-sized buffer that hold relative coordinate for each pixel. That mean that each pixel of the final image will have on this buffer a coordinate from where the final color come from.
  2. the final image is computed from the original image and this buffer.

The approach with a coordinate buffer instead of acting directly on the image allows to:

  1. Render the tool effect in a constant time, no matter the number of stroke.
  2. No information lost. See for example the case of a pinch done multiple times in the same area so the input pixel would collapse. If you un-pinch the area, the map-absolute operator will fetch the right pixels, with no data loss.

Potential behavior

This technical approach gives a good liberty when implementing behavior. Following is a list a potential behavior, but other can be found and implemented.

  1. drag: the stroke moves pixels under the cursor
  2. swirl (left and right)
  3. cancel: cancel the transformation locally (ie set the relative coordinate to zero)
  4. pinch/concentrate
  5. expand
  6. smooth: tend to flatten the transformation

Tool options

This tool would have as options at least:

  1. size of the effect
  2. shape of the effect (round or square ?, sharp or smooth edge ?)

This part, as the others, need to be thought in details, an probably expanded.


Undo should be achievable with this tool. What is exactly doable (one step undo ? more ?) is currently unclear and need to be discussed.

Right now, i see two way to achieve that:

  1. keeping copies of the coordinate buffer
    1. it will quickly eat a lot of memory
  2. applying the stroke in reverse,
    1. it lead to approximation problem
    2. not all behavior are easy to undo (see for instance the cancel or smooth behavior)
  3. recording all the stroke applied, and recomputing the coordinate buffer when undoing
    1. can take a lot of time if there is many strokes


Since editing the coordinate buffer and rendering the transformation are two separated process, we can render the image with different quality without affecting the deformation.