Hacking:WarpTool/UI design info

From GIMP Developer Wiki
Jump to: navigation, search

Contents

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. move: the stroke moves pixels under the cursor
  2. swirl (left and right) - rotary transform
  3. erase transform: cancel the transformation locally (ie set the relative coordinate to zero)
  4. pinch/concentrate
  5. expand
  6. smooth: tend to flatten the transformation

All operations are applied with a feathered "brush", so effect is largest at center and smallest at edge.

Tool options

This tool would have as options at least:

  1. size of the effect
  2. shape of the effect (round or square ?) -i dont think offering other shapes than round provides much... AlexiaDeath 20:41, 2 June 2011 (UTC)
  3. Hardness of the effect (see hardness in round brushes)

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

Undo

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

Possible 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
  4. mixed solution: keeping "keyframe" coordinate buffer, every n stroke + every strokes, and recompute from this keyframe when undoing
  5. keeping modified tiles for every stroke done, and recompose a buffer when undoing
  6. stack one gegl op for each stroke in a gegl graph to compute the final coordinate buffer, and unstack op for undo

Quality

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.

Pressure sensitivity

Options like the size of the effect or the sharpening of the shape could be pressure sensitive.

Personal tools