Changed brush engine to allow preserving lightness in brushtips, and using...

I submitted a request for a feature, and then decided to implement it myself. Go to to see the discussion.

I added an option to the brush chooser, such that when "Use Color as Mask" is selected, you can also choose to preserve the lightness in the image. I implemented changes in the brush engine so that if "Preserve lightness" is selected, it uses the alpha channel already in the brushtip for alpha, and keeps the lightness value of the brush tip, in such a way that any blacks or dark parts and any whites and light parts of the brushtip are preserved, and scale to the chosen color for anything in between. This allows an artist to create stamps of an image (say leaves, or flowers) that has shadows, or outlines, or highlights, and when they paint with it, those outlines and/or highlights are preserved, but they can choose any color instead of the original color. A lot of other things can probably be done with this too.

I added an option when creating a brush and choosing "Create Mask from Color" to preserve alpha in the image. This saves the brushtip as a grayscale image, but it's still in full RGBA, with the original alpha, so it can be used with the new lightness option described above.

The above options also work with animated brushes.

If the options added are not selected, everything should work as they did before. So far, everything I've tested works as expected. I have not done extensive testing on all existing brushes, so I can't guarantee I didn't break anything, but so far haven't come across any issues.

Merge request reports