Selections
Boudewijn Rempt
boud at valdyas.org
Mon Aug 23 22:22:19 CEST 2004
I've added the beginning of a design document for selections in Krita to CVS,
but I'm also mailing to the list so we can discuss the places where I'm
unsure about how to proceed.
Selections in Krita
Please disregard any lingering presence of the KisFloatingSelection
class and the associated rectangular marque rendering code. If you
find anything connected with that after I finish coding the new
selections scheme, it's something I forgot.
Selections in Krita are special paint devices as big as their parent
layer. Until Krita can compose heterogenous images (i.e., with layers
of a different type), selections have the same colour strategy as
their parent layer. The alpha channel then contains the selections
channel; selectedness of a pixel is not a binary value, but a scale,
provisionally 8 bits. More might be needed, but I doubt it.
The color/gray channels of a selection paint device contains the color
of the mask. On creation, the selection is filled with the selected
mask color. If during the lifetime of the selection the mask color is
changed, the layer is filled again with the new color.
TODO: * implement heterogenous compositing
* create an 8-bit KisAlphaMask color strategy that composits
using a given color and the alpha pixel value.
Selections can be changed using tools that are clones of the usual
painting tools: brush, eraser, polygon, etc.
TODO: * implement most of these, the polygon, circle, rectangle tools
should fill by default.
XXX: Fill-by-default should be an option for the polygon, circle,
rectangle painting tools, too.
Selections can also changed by procedures like select-by-color etc.
TODO: * finish dialog for select by color
* implement select-by-color (depends on usable iterators)
Selections are represented as a colored mask of a certain opacity
where more transparent == more selected.
Other representations of selections are possible: the selection for a
particular rect is rendered as a separate step in
KisImage::renderToProjection. I like the mask type rendering, but
someone else might want to provide an optional marque-rendering.
TODO: * enable kconfig option to select between renderings.
Selected pixels can be mangled -- for instance, filled with a
gradient, moved, made brighter, lighter or sprightlier, cut and
pasted. These manglings fall into two groups: the kind that demands
that the selected pixels are removed from their native layer, and the
kind that merely changes their value.
A) Moving, cutting, copying, pasting.
Each of these operations moves pixels to a new KisLayer that is not
part of the regular stack of layers. The operations are defined as
follows:
Moving: create new layer, copy selected pixels to this layer, set
pixels in old layer to transparent background colour, set new layer
visible.
Cutting: create new layer, copy selected pixels to this layer, set
pixels in old layer to transparent background colour, add new layer to
the cut scrapbook (if we're going to have such a thing).
XXX: Discuss desirability of cut scrapbook.
Copying: create new layer, copy selected pixels to this layer, add new
layer to the cut scrapbook (if we're going to have such a thing).
Pasting: check if cut or copy layer exists in scrapbook, copy pixels
from this layer to the target layer.
B) Changing the value of selected pixels
Use cases: fills (gradient, pattern, color), filtering.
Fills are easiest implemented by creating a filled paint device for
the rect covered by the selection, and then, while composting the fill
with the target layer, pass the mask to the compositing loop, and skip
un-selected pixels.
XXX: Discuss whether this is true
Filtering needs looping over all pixels of a layer, and, if selection
is present, only apply filter to the selected pixel.
XXX: What about convolving, which takes a matrix of pixels. If only
the middle pixel of a matrix is selected, should we take the input of
the surrounding unselected pixels, or should the operation then assume
edge conditions? Or should this be an option?
TODO: infrastructure for all these operations, actual implementation.
More information about the kimageshop
mailing list