Hacking:WarpTool/UI design info
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é (firstname.lastname@example.org, irc: Bat`O on #email@example.com).
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:
- 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.
- 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:
- Render the tool effect in a constant time, no matter the number of stroke.
- 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.
This technical approach gives a good liberty when implementing behavior. Following is a list a potential behavior, but other can be found and implemented.
- drag: the stroke moves pixels under the cursor
- swirl (left and right)
- cancel: cancel the transformation locally (ie set the relative coordinate to zero)
- smooth: tend to flatten the transformation
This tool would have as options at least:
- size of the effect
- 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:
- keeping copies of the coordinate buffer
- it will quickly eat a lot of memory
- applying the stroke in reverse,
- it lead to approximation problem
- not all behavior are easy to undo (see for instance the cancel or smooth behavior)
- recording all the stroke applied, and recomputing the coordinate buffer when undoing
- can take a lot of time if there is many strokes
- mixed solution: keeping "keyframe" coordinate buffer, every n stroke + every strokes, and recompute from this keyframe when undoing
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.