Рубрики

purple

Charming color mix with purple

Described as a reddish brown—and, oftentimes, finished with purple undertones, resembling its eponymous wine varietal—burgundy is arguably one of the more overlooked shades on the color palette. Sure, many design enthusiasts might flock to a fiery red or the pared-down vibes brown has to offer, but a shade that does both? Not exactly. However, burgundy is an incredibly versatile shade; one that can take on a whole new look when paired with certain colors.


Color mixing in android

I am working on application in which i have five colors:Red,Green,Blue,Yellow,purple I want to implement color mixing from those colors:such that like there are five button for each color. User touch whichever color button this color mix with previously drawn color. I have not any clue how to add two color codes and get third color. EDitED: I have to also set this color to imageview’s bitmap how can i set this?

Follow
chikka.anddev
asked May 20, 2011 at 9:48
chikka.anddev chikka.anddev
9,599 7 7 gold badges 38 38 silver badges 46 46 bronze badges

8 Answers 8

Sorted by: Reset to default

Since April 2015 you can use blendARGB method from v4 support library:

int resultColor = ColorUtils.blendARGB(color1, color2, 0.5F);

Ratio value has to be 0.5 to achive even mix.

Follow
answered Jul 27, 2016 at 20:20
Szymon Grochowiak Szymon Grochowiak
650 1 1 gold badge 5 5 silver badges 6 6 bronze badges
Perfect also for setting lighter/darker hues of a color!
Feb 22, 2018 at 10:19

The 3rd argument is ratio(the proportion while blending the colors). eg. If you want 30% of color1 & 70% of color2, then do ColorUtils.blendARGB(***, ***, 0.3F);

Mar 11, 2018 at 0:37

An alternative answer:

You can mix the bits in the hexs:

public static int mixTwoColors( int color1, int color2, float amount ) < final byte ALPHA_CHANNEL = 24; final byte RED_CHANNEL = 16; final byte GREEN_CHANNEL = 8; final byte BLUE_CHANNEL = 0; final float inverseAmount = 1.0f - amount; int a = ((int)(((float)(color1 >> ALPHA_CHANNEL & 0xff )*amount) + ((float)(color2 >> ALPHA_CHANNEL & 0xff )*inverseAmount))) & 0xff; int r = ((int)(((float)(color1 >> RED_CHANNEL & 0xff )*amount) + ((float)(color2 >> RED_CHANNEL & 0xff )*inverseAmount))) & 0xff; int g = ((int)(((float)(color1 >> GREEN_CHANNEL & 0xff )*amount) + ((float)(color2 >> GREEN_CHANNEL & 0xff )*inverseAmount))) & 0xff; int b = ((int)(((float)(color1 & 0xff )*amount) + ((float)(color2 & 0xff )*inverseAmount))) & 0xff; return a

Follow
answered Nov 17, 2013 at 22:35
Ratata Tata Ratata Tata
2,799 1 1 gold badge 34 34 silver badges 49 49 bronze badges
What is amount ?
Aug 9, 2017 at 7:38

The amount you want of one color blended to the other. For an instance, you want 0.3 of color1 and 0.7 of color2, you use mixTwoColors( . . 0.3 ).

Aug 10, 2017 at 18:35

SlidingTabStrip has really useful method for blending colors, looks great when used with ViewPager:

private static int blendColors(int color1, int color2, float ratio)

Follow
77.2k 107 107 gold badges 162 162 silver badges 262 262 bronze badges
answered Jun 18, 2014 at 12:16
Marqs Marqs
17.9k 4 4 gold badges 30 30 silver badges 40 40 bronze badges
What is ratio ?
Aug 9, 2017 at 7:38

If colors are in RGB space, it is pretty simple (but the result is sometimes not that satisfying):

public int mixColors(int col1, int col2) < int r1, g1, b1, r2, g2, b2; r1 = Color.red(col1); g1 = Color.green(col1); b1 = Color.blue(col1); r2 = Color.red(col2); g2 = Color.green(col2); b2 = Color.blue(col2); int r3 = (r1 + r2)/2; int g3 = (g1 + g2)/2; int b3 = (b1 + b2)/2; return Color.rgb(r3, g3, b3); >

If you want to use other color spaces, search Wikipedia and find HSL color space. You also have some libraries to do that for you.

Then you will have to read this question: Calculation of a mixed color in RGB

Follow
1 1 1 silver badge
answered May 20, 2011 at 9:52
Vincent Mimoun-Prat Vincent Mimoun-Prat
28.2k 16 16 gold badges 83 83 silver badges 124 124 bronze badges
thnx for reply bt i have 5 colors not only rgb.
May 20, 2011 at 10:07

RGB are the components of each color. So you have 5 times RGB. You need to combine the answer from Luis Miguel Serrano and mine.

May 20, 2011 at 10:15

Thanx for reply.But i need more color space with using above function on five mixes it will stay on constant color.What should better sol for more color space mixing?

May 27, 2011 at 5:59

@MarvinLabs you are aware that your answer as well the linked one are very bad for mixing RGB colors (you say that yourself), so why include it ? Barycenter interpolation gives much more meaningful results for RGB (which is a bad color system nevertheless). With three colors, some yellow one, a brown one, and a pink, you would get this: i.imgur.com/thLiR.png. It can be extended to n points.

Jan 5, 2013 at 13:18
Follow
answered Jul 15, 2014 at 21:43
IuriiO IuriiO
611 7 7 silver badges 13 13 bronze badges

Great, I use it to tint colors having full lightness already, by blending the color with white. Works great.

Dec 26, 2014 at 10:13

Bizzre choice of API by android developers. Needlessly requires an instance. Needlessly takes Object parameters which promptly get cast to Integer. Should not be used in realtime drawing or animation code because of boxing and unboxing allocations. So you know. (Thanks to original poster; no thanks to the Android dev that wrote this attrocity).Better to just swipe oen of the other code fragments in this posting.

Jul 13, 2015 at 15:12

This example may by useful if you want blend two colors (foreground and background). Based on Orlando Leite answare and wikipedia http://en.wikipedia.org/wiki/Alpha_compositing, proper way to blend two colors with alpha is:

public static int MergeColors(int backgroundColor, int foregroundColor) < final byte ALPHA_CHANNEL = 24; final byte RED_CHANNEL = 16; final byte GREEN_CHANNEL = 8; final byte BLUE_CHANNEL = 0; final double ap1 = (double)(backgroundColor >> ALPHA_CHANNEL & 0xff) / 255d; final double ap2 = (double)(foregroundColor >> ALPHA_CHANNEL & 0xff) / 255d; final double ap = ap2 + (ap1 * (1 - ap2)); final double amount1 = (ap1 * (1 - ap2)) / ap; final double amount2 = amount1 / ap; int a = ((int)(ap * 255d)) & 0xff; int r = ((int)(((float)(backgroundColor >> RED_CHANNEL & 0xff )*amount1) + ((float)(foregroundColor >> RED_CHANNEL & 0xff )*amount2))) & 0xff; int g = ((int)(((float)(backgroundColor >> GREEN_CHANNEL & 0xff )*amount1) + ((float)(foregroundColor >> GREEN_CHANNEL & 0xff )*amount2))) & 0xff; int b = ((int)(((float)(backgroundColor & 0xff )*amount1) + ((float)(foregroundColor & 0xff )*amount2))) & 0xff; return a

In this case alpha channel is used to compute percentage RGB share in blending. Background color may be visible only i foreground alpha is smaller than 100%




Burgundy + Lapis: Elegant & Bold

burgundy+Lapis

Looking for an elegant way to incorporate primary colors into your space? Take a cue from Texas-based designer Nina Magon, who juxtaposed a burgundy chair with bright blue sectional. Set against a high-contrast backdrop, these alternate takes on red and blue pack a punch without look overtly patriotic.

02 of 15

Burgundy + Navy: Classic & Powerful

burgundy+navy

If lapis feels a bit bright for your design taste, add some navy to the mix. When peppered in an all white room—like this one Emily Henderson designed—this power combination feels undeniably modern.

03 of 15

Burgundy + Mint: Unexpected & Fun

burgundy and mint

Balance the mix of warm and cool tones by juxtaposing burgundy with mint.

“Burgundy can get a bad wrap that conjures up dining rooms and studies from the 80’s, but fear it no more,” says Julie Massucco Kleiner, co-founder and principal at Massucco Warrner. “In this bedroom and dressing area that we designed, we layered the burgundy DeGournay wallpaper with metallics, lucite, and a fresh assortment of pattern to make it anything but stuffy!”

04 of 15

Colin Wynn
the authorColin Wynn

Leave a Reply