gColor Mixing
Site Map Feedback

Download:

Up Colour Spline HSL HSV Mixers Shaders
gColor provides several Mix/Blend methods. Each take a parameter, t (Interval [0,1]), a Colour to mix and a boolean to say if the mix should be Greyscale (faster). There are also static versions which take two colours and two parameters, and a Mix method that takes an enum with the type of mix being an enum passed in. Most people just play to find out what each mode does, writing (or reading) descriptions of each method is less helpful than getting a feel from experience. Start with mixing greyscale images.
If the greyscale level is turned to an Interval in the range [0.1], multiply will keep the mix in that interval: the result will be black where either image is black.
If you expected blend to work, but ended up with white areas becoming grey, try Screen.
If t is 0 or 1 it may be wiser not to use a method here, for example, Multiply(Brush,1,Screen,0) is just going to return Brush*Screen;
Sometimes seeing what's under the hood helps a little:
Blend (Normal) :Screen* (1-t) + t*Brush Normal transparency blend.
Multiply :Screen*((1-t) + t*Brush)
Screen :1-((1-t) + t*(1-Brush)) * (1-Screen) A Blend of opposites: Negative(Blend(Negative(Brush), Negative(Screen));
Overlay :Screen<0.5 ? Screen*((1-t) + 2*t*Brush) : 1-((1-t) + 2*t*(1-Brush)) * (1-Screen)
Divide :Brush==0 ? Screen : (1-t)*Screen + t*Screen/Brush
Difference :(1-t)*Screen + t*fabs(Screen-Brush)
Subtract :Screen-=t*Brush
Add :Screen+=t*Brush
Darker :t*Brush<Screen ? t*Brush : Screen
Lighter :t*Brush>Screen ? t*Brush : Screen
Dodge :Doesn't effect dark areas. Saturates, adding 'heat'.
Burn :Doesn't effect light areas. Saturates, adding 'heat'.
Hue :Color only. Screen.Hue=Brush.Hue
Saturation :Color only. Screen.Saturation=Brush.Saturation
Color :Color only. Screen.HueAndSaturation=Brush.HueAndSaturation
Value :Color only. Screen.Value=Brush.Value
Note: The resulting colour can exceed the normal [0-1] Interval for each component (Add, really does blindly add)!


THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 'AS IS' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.