Jump to content

How Can I Blend Colors Together?


Recommended Posts

I'm terrible at math, but I would suggest you play with the colors window. If you are new, you can learn about the color window here : http://www.getpaint.net/doc/latest/ColorsWindow.html

 

If you just want to play around with mixing colors, you could also play with layer blending modes. Paint one color on one layer, paint another color on an above layer, and then change the above layer's blending mode. If you make a color you like, you can use the color picker tool. When you have the color picker tool active, observe the tool's options, which are just under the menu bar. You should see a place that says “Sampling: Layer” change it to “Image”. Then click on your new color. In the colors window you can “add” the color to your palette.

Link to post
Share on other sites

If you just want to play around with mixing colors, you could also play with layer blending modes. Paint one color on one layer, paint another color on an above layer, and then change the above layer's blending mode. If you make a color you like, you can use the color picker tool. When you have the color picker tool active, observe the tool's options, which are just under the menu bar. You should see a place that says “Sampling: Layer” change it to “Image”. Then click on your new color. In the colors window you can “add” the color to your palette.

Hmm. But I'm not sure which blending mode will achieve what I want to.

 

You see, I'm following a color tutorial that says to mix two colors into a new one in order to create a new color that still fits with the others. So, for example, I want to take exactly 60% of a certain blue and mix it with exactly 40% of a certain green to make a new color.

Link to post
Share on other sites

Its a complex method to achieve color blending, but here we go...

1. Select your blue color as the Primary color.

2. Create a new layer (layer B )

3. In the new layer, drag out a blue rectangle using the Shapes tool.

4. Select the example green color as the Primary color.

5. Create a new layer (layer C)

6. In the new layer, drag out a green rectangle using the Shapes tool which overlaps one corner of the blue rectangle.

7. Double click Layer C to open the Properties dialog.

8. Blend mode = Normal.

9. Opacity = 102 (which is 40% of the maximum 255).

10. Flatten Layers B and C.

11. With the Color Picker tool, find the color of the overlap.

yhsjjie_34.png

Link to post
Share on other sites

Its a complex method to achieve color blending, but here we go...

1. Select your blue color as the Primary color.

2. Create a new layer (layer B )

3. In the new layer, drag out a blue rectangle using the Shapes tool.

4. Select the example green color as the Primary color.

5. Create a new layer (layer C)

6. In the new layer, drag out a green rectangle using the Shapes tool which overlaps one corner of the blue rectangle.

7. Double click Layer C to open the Properties dialog.

8. Blend mode = Normal.

9. Opacity = 102 (which is 40% of the maximum 255).

10. Flatten Layers B and C.

11. With the Color Picker tool, find the color of the overlap.

yhsjjie_34.png

I'm about to sleep, so I'll try this out tomorrow and report back.

 

But it seems like exactly what I asked for from reading, so thanks in advance!

Link to post
Share on other sites

Would using the gradient tool with paint.net's rulers enabled, help at all? For example, if I use a blue color as my primary color and green as my secondary color and then draw the gradient (while holding shift) according to the ruler (0 - 800 on default canvas), the center of the gradient (at 400, 300) would be the single new color, but since it's a gradient there would also be the transition colors. With the help of the rulers, as well as the coordinates of the mouse, which are displayed at the bottom of paint.net, perhaps some math like percentages can be figured out. (note: the arrow keys on a keyboard can move the mouse one pixel at a time for exact placement). Re-sizing the canvas could make some of the math easier too, since you can literally make the canvas 100 by 100 or even 12 by 1.

 

I would think this idea could be useful in some cases. Unless the gradient's transitions or paint.net's rulers aren't accurate?

Link to post
Share on other sites

Here's a little CodeLab plugin the might be helpful. I call it the "Two Color Mixer" ( I chose a name that probably won't be used by some more commonly used plugin). It's in the Effects>Render menu. You can specify two colors, and the percent of the first color. It will fill the current selection (or the whole window if no selection) with the mixed color.

 

Code:

Hidden Content:
// Author: MJW
// Name: Two Color Mixer
// Title: Two Color Mixer
// Submenu: Render
// Desc: Fill a region with a mixture of two colors
// Keywords: mix colors
#region UICode
ColorBgra Amount1 = ColorBgra.FromBgr(0, 0, 0); // First Color
ColorBgra Amount2 = ColorBgra.FromBgr(0, 0, 0); // Second Color
bool Amount3 = false; //[0, 1] Use Primary Color as First Color and Secondary Color as Second Color
double Amount4 = 50; // [0, 100] Percent of First Color in Mixture
double Amount5 = 1; //[0, 4] Brightness
double Amount6 = 1; //[0, 4] Saturation
#endregion


// Here is the main render loop function
void Render(Surface dst, Surface src, Rectangle rect)
{
    ColorBgra color1, color2;
    double dr, dg, db, da;
    byte r, g, b, a;
    double frac = 0.01 * Amount4;
    double omfrac = 1.0 - frac;
    if (Amount3)
    {
        color1 = (ColorBgra)EnvironmentParameters.PrimaryColor;
        color2 = (ColorBgra)EnvironmentParameters.SecondaryColor;
    }
    else
    {
        color1 = Amount1;
        color2 = Amount2;
    }
    dr = frac * (double)color1.R + omfrac * (double)color2.R;
    dg = frac * (double)color1.G + omfrac * (double)color2.G;
    db = frac * (double)color1.B + omfrac * (double)color2.B;
    da = frac * (double)color1.A + omfrac * (double)color2.A;
    double min = Math.Min(dr, Math.Min(dg, db));
    double max = Math.Max(dr, Math.Max(dg, db));
    
    // Saturation
    double diff = max - min;
    double ks = Amount6;
    if (ks * diff > max)
        ks = max / diff;
    dr = max - ks * (max - dr);
    dg = max - ks * (max - dg);
    db = max - ks * (max - db);

    // Brightness
    double kb = Amount5;
    if (kb * max > 255.0)
        kb = 255.0 / max;

    r = (byte)(kb * dr + 0.5);
    g = (byte)(kb * dg + 0.5);
    b = (byte)(kb * db + 0.5);
    a = (byte)(da + 0.5);

    ColorBgra mixture = ColorBgra.FromBgra(b, g, r, a);
 
    for (int y = rect.Top; y < rect.Bottom; y++)
    {
        if (IsCancelRequested) return;
        for (int x = rect.Left; x < rect.Right; x++)
        {
            dst[x, y] = mixture;
        }
    }
}



 

Plugin: TwoColorMixer.zip

 

EDIT: Added the ability to choose the Primary and Secondary Color as the colors to mix. This might be useful, since it more easily allows the Color Selector tool to select the colors.

EDIT: Added adjustments for the brightness and saturation of the mixed color.

EDIT: See further down in the thread for a 3.5.11-compatible version.

Link to post
Share on other sites

I'd be happy to do so, but I'm not sure how. Given it's CodeLab plugin, I assume it depends on the version of CodeLab I'm using.

 

If you have CodeLab, I think you can probably compile it youself, since I posted the source code.

 

Here's the (very simple) icon: post-53337-0-17144300-1431997625.png

Link to post
Share on other sites

Nice icon ;)

@Maximillian: Recompiling the plugin code with CodeLab will make it compatible with your version. The question is.... why haven't you updated to paint.net 4?

Link to post
Share on other sites

Tested Ego Eram Reputo's method - it works. A bit annoying, but works.

 

Although, I found the blend tool site thingie I posted above after I had already posted this thread, and honestly, it's so simple and to the point to use that I'll probably just use that for blending from now on.

 

But anyway, thanks to who replied! =D

Link to post
Share on other sites

@Maximillian: Recompiling the plugin code with CodeLab will make it compatible with your version. The question is.... why haven't you updated to paint.net 4?

 

I'd really love to. My problem is my PC is still running on an outdated operating system, plus it's an old machine and I doubt it will cope with the demands of a newer OS. To top it off, there's too little free space in the hard drives and not much RAM... yeah, I could use a new computer ignat_01.gif

Link to post
Share on other sites

Thanks in advance to both of you for the efforts!

 

I'm experiencing a bit of a curious problem. There seems to be a conflict between my 3.5.11 version of Two Color Mixer and Tanel's Color Mixer (a completely different plugin). The latter shows up in the Adjustments menu. When I install Two Color Mixer I have to rename the DLL to TwoColorMixer.dll because the above posted zip file has it as Colormixer.dll and Tanel's plugin already has the name Colormixer.dll reserved for itself.

 

And after renaming and installing, I now have two instances of Tanel's Color Mixer in the Adjustments menu and Two Color Mixer is nowhere, though it should be in the Render menu.

 

Red, can you look into it one more time, please? I have tried to compile it myself since I now have the 3.5.11 version of Codelab, but even when the DLL appears to be created successfully, I can't get it to work. There must be something wrong in my system, or most likely it's all due to my lack of skills at coding and I can't detect the problems by myself ignat_01.gif

Link to post
Share on other sites

Maximilian, just renaming a dll will not change the names of the effect classes inside of the dll. so if there is a conflict with the class names of the effects and Paint.NET ignores this conflict then it is not a big surprise that you are getting two times the first effect Paint.NET has found.

midora%20signature.gif
Link to post
Share on other sites

Assuming the plugin name is still Two Color Mixer, I don't know why there would be a conflict. I selected the name with the intent on avoiding conflicting with any future, more generally useful, plugin.

Link to post
Share on other sites

I tried to compile the DLL one more time (with Codelab 1.8, last available version of Codelab for PdN 3.5.11) but I keep getting the same error:

 

 

File: C:\Archivos de programa\Paint.NET\Effects\TwoColorMixer.dll
      Name: TwoColorMixerEffect.TwoColorMixerEffectPlugin
      Version: 1.0.5618.34297
      Author: MJW
      Copyright: Copyright © MJW
      Website: http://www.getpaint.net/redirect/plugins.html
      Full error message: System.ArgumentOutOfRangeException: Specified argument was out of the range of valid values.
Parameter name: defaultValue > maxValue
   at PaintDotNet.PropertySystem.ScalarProperty`1..ctor(Object name, T defaultValue, T minValue, T maxValue, Boolean readOnly, ValueValidationFailureResult vvfResult) in D:\src\pdn\pdn_3_5_11\src\Base\PropertySystem\ScalarProperty`1.cs:line 136
   at PaintDotNet.PropertySystem.DoubleProperty..ctor(Object name, Double defaultValue, Double minValue, Double maxValue) in D:\src\pdn\pdn_3_5_11\src\Base\PropertySystem\DoubleProperty.cs:line 27
   at TwoColorMixerEffect.TwoColorMixerEffectPlugin.OnCreatePropertyCollection()
   at PaintDotNet.Effects.PropertyBasedEffect.CreateConfigDialog() in D:\src\pdn\pdn_3_5_11\src\Effects\PropertyBasedEffect.cs:line 86
   at PaintDotNet.Menus.EffectMenuBase.RunEffectImpl(Type effectType) in D:\src\pdn\pdn_3_5_11\src\PaintDotNet\Menus\EffectMenuBase.cs:line 799

 

Link to post
Share on other sites

Try it with the the new version of the source code I posted. There used to be a weird bug where CodeLab would confuse a Double Slider with an Angle Control. As I recall, it happened when the double values were specified with decimal points. Just in case, I changed the default values from 1.0 to 1. It may not help, but it's worth a try.

Link to post
Share on other sites

You're welcome to post it yourself, Red ochre. I'm not so possessive that I won't allow anyone else to post another version of the plugin. (Of course, if you'd prefer I post it, I'd be happy to do so.)

Link to post
Share on other sites

I've recompiled as 'Twocolormixer' - only added your Icon. Had a quick test with the extremes of the sliders...I couldn't get it to crash.

 

Attaching with MJW's permission.(thanks)

 

Twocolormixer.zip

 

 

 

Red ochre Plugin pack............................................................... Diabolical Drawings

 

PdnForumSig2.jpg

Link to post
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...