Paint Bucket Tool

images\btn_paint_bucket.gif The Paint Bucket tool fills regions of similarly colored pixels with foreground color. There are four subtleties involved in using the Manifold paint bucket tool as compared to use of such tools in simpler graphics software:


·      By default, the paint bucket tool pours color only into pixels contiguous with the point where the tool is clicked. Override this by using a SHIFT click.

·      The paint bucket affects only selected pixels. If there is no selection, the paint bucket will operate on the entire image.

·      The paint bucket pours color only into those pixels whose color values are within the Tolerance value set in the Tool Properties pane . Override the Tolerance consideration by using an ALT click.

·      Use a CTRL click to paint color with the paint bucket while preserving the intensity levels of the previous colors. This is like a paint bucket "colorize" effect.


images\btn_paint_bucket.gif To use this tool we click on the Paint Bucket tool in the Tools toolbar for images. In the examples below we use a foreground color of purple. These examples will use the sample bronze image that has had the Threshold command applied to convert it to only black and white colors. This will show the effect of the paint bucket tool in a simplified image.



When the paint bucket is enabled Manifold changes the mouse cursor to a simple cross icon as shown above. We will click onto the black region at the rear of the monument.



The paint bucket pours purple foreground color into all black pixels that are contiguous with the pixel where the tool was clicked. Note that regions of black pixels in the image not contiguous with the click have not been colored.


Using the SHIFT Key



If we click at the same spot using a SHIFT click the paint bucket will pour purple color into all of the black pixels in the image no matter where they are located. This is a useful technique to replace one color with another throughout all pixels in the image.


When a Selection is Present



Suppose we select a rectangular region of pixels and SHIFT click with the paint bucket at the spot shown. The paint bucket tool will compute the pixels to be affected based on the color at the spot clicked but it will paint color only into those pixels that are within the selection.



If we switched foreground color to green and SHIFT clicked at the spot shown in the preceding illustration the paint bucket will paint green color into all of the black pixels within the selection.


Tolerance Parameter


The paint bucket tool measures the color value of the pixel at the point where it is clicked and then operates on pixels whose colors fall within the Tolerance parameter set in the Tool Properties pane. This is different than the default behavior of paint bucket tools within simpler graphics editors such as Microsoft Paint, where a paint bucket pours into all pixels of like color, or where the paint bucket pours into any selected region without regard to the color of pixels it is painting.


When painting into regions of pixels that are all the same color the use of the Tolerance parameter does not matter since in that case all of the pixels probably will fall within tolerance value being used. The Tolerance parameter most likely will make a difference when painting into regions of gradients or subtle transitions between colors.



Let's look at an example using an image that contains a smooth gradient of color from blue to purple. Suppose we change foreground color to yellow and click the paint bucket tool at the spot indicated above. If we are familiar with the default behavior of paint bucket tools in simple graphics editors we might expect the yellow color to fill the entire selected region.



In Manifold, given typical default settings of Tolerance we might get the above effect. What happened?


images\img_paint_bucket_t07.gif If the Tolerance parameter in the Tool Properties pane is set to a low value, such as 10, the paint bucket tool will paint only those pixels that are close in color to the one originally clicked. Blue colors close to that clicked were colored and blue colors transitioning to purple were also colored if they were not so purple that they fell outside the Tolerance range of 10. Because the gradient in the example image was created using the Gradient tool , the transition in colors in the image occurs in a smooth diagonal gradation from upper left to lower right. The pixels affected by the paint bucket tool thus fall within an even, rhomboid region within the selection. The clearly defined edge of the region painted yellow by the paint bucket occurs because that is the edge at which pixels pass beyond the tolerance difference of 10.


images\img_paint_bucket_t08.gif To color the entire selected region with the paint bucket we can simply increase the Tolerance parameter so that a wider range of pixels will be affected.



The result of clicking the paint bucket at the same spot with a Tolerance of 100 is that the yellow color is poured into the entire selected region. We can also get the same effect with an ALT click.


The ALT Key


Wishing to pour a paint bucket of color throughout a selected region is such a common operation that Manifold provides a faster way to do so than resetting the Tolerance parameter. Pressing the ALT key while clicking to pour the paint bucket will have the effect of pouring with maximum tolerance for that pour. The paint bucket will fill all selected regions regardless of their previous pixel colors. If there is no selection the entire image will be painted.



Suppose we select a rectangular region of pixels in the sample bronze image and click with the paint bucket at the spot indicated, using a foreground color of yellow.



If the Tolerance parameter is at the usual setting of 16 or so, the paint bucket will fill pixels that are blue in color and close to the blue of the pixel that was clicked. Note that the paint bucket action is computed over the entire image but applied only within the selected region. Thus, the pixels on the other side of the box from the spot clicked are contiguous (considering the entire image) within the given tolerance to the spot clicked. Most of the blue sky would be painted were it not for the selection; however, the yellow color is painted only into the pixels that are within the selection.



Had we ALT clicked with the paint bucket at the spot indicated all pixels within the selected region would have been painted.


The CTRL Key


The CTRL key may be used when clicking with the paint bucket to preserve the intensity of colors while painting with the foreground color. The CTRL key may be used in combination with either the ALT key or the SHIFT key.



Suppose we select all pixels within the bronze monument and click at the indicated position with the paint bucket using yellow color.



A CTRL- ALT click will pour yellow color into the entire selection while preserving intensity levels from the colors previously in use. The effect is like doing a Colorize with the paint bucket.



Clicking at the same spot with just an ALT click will pour color into the entire selection without preserving intensity levels.


Local Clicks Apply throughout the Image


The paint bucket tool computes its action based on the spot that it is clicked regardless of whether this spot is inside or outside the selection. If a selection exists, the action of the paint bucket will be limited to the selected regions but it will also apply to all selected regions even if they are not connected with each other. This allows us to apply paint bucket action using the color of pixels at whatever location is easiest to click even if we intend the tool to apply only within the selection.


When used with the ALT key to paint throughout the selection, this means we can click very rapidly without having to worry about clicking within the selection.



If we CTRL- ALT click as shown above the paint bucket will pour color into all selected regions, preserving the intensity. Note that it does not matter whether or not we clicked inside or outside of any of the selected regions.



We would have had the same effect if we had CTRL clicked at that spot (or at any other spot) with very high Tolerance setting in the Tool Properties pane. Using the ALT key is a handy way of painting throughout all selected regions without having to be precise in our application of the paint bucket tool.


This effect of the Manifold paint bucket tool is different than what is encountered in some other graphics software, where a paint bucket tool applies to a region contiguous to where it is clicked. For example, clicking a paint bucket tool on the blue sky as shown above in some graphics editors would have resulted in a flood of yellow paint throughout all regions of the image except the selected areas. Clicking within any one of the selected regions would have painted only that region and not the other selected portions.


Manifold works differently because Manifold has a very strong set of selection tools that ordinary graphics editors do not have. Given Manifold's powerful selection methods the design philosophy of the system is that one makes a selection that is to be affected and then one applies tools to that selection. If we wanted to paint all the regions except those selected we would have taken a moment to use Edit - Select Inverse to invert the selection and then painted with the paint bucket. A strong array of tools for making selections, saving them and modifying them lets us choose exactly the region in which we wish our painting tools to apply.




Note that the use of Tolerance to guide the action of the paint bucket tool is not a negative thing: it is a powerful capability that allows the paint bucket tool to be used with fine control for replacing colors over a desired range of values. If we want the paint bucket to work without regard to Tolerance setting we simply ALT click.


When the paint bucket tool is in action, Manifold changes the mouse cursor to a simple cross icon. This is different than the cursor style used by some other software products for this type of tool. Other software programs will often use a small paint bucket icon for their mouse cursors. This has the advantage of showing what painting tool is in use, but such cursor shapes make it much more difficult to click with precision upon a desired spot. Manifold's cross cursor for the paint bucket tool makes it immediately clear where the tool is clicked.


Sometimes we would like to know in advance where the paint bucket will pour without having to Undo the operation. To see where the paint bucket will pour, use Select Touch to click on the spot where the pour will be made. Because Select Touch also selects pixels using the Tolerance set in the Tool Properties pane, it will select the same pixels that would be affected by a paint bucket pour. To avoid altering a pre-existing selection, save that selection first in the Selections pane so that it can be recalled after the Select Touch selection.


When using the paint bucket the CTRL key may be combined with either the ALT key or the SHIFT key. We can do a CTRL-ALT click or a CTRL-SHIFT click; however, the ALT and SHIFT key don't make sense to use together since their combined action is equivalent to an ALT click.


See Also


See the example Painting into the Alpha Channel for an example of how the paint bucket tool may be used to paint into the alpha channel of an RGBa image. The paint bucket tool when used as the example shows is a very handy way of adjusting alpha transparency in partially transparent images.