I have these cards that have two color shades on them. A main color, and then a darker accent color:
The main color is given to me in hex, but not the accent. Can you tell what kind of blend or transformation is being done to the ARGB of the main color to get the darker accent color?
If it matters, I'm developing against Android so I've got access to the Color class and ColorFilter so I can apply all that PorterDuff stuff...
If you want darker Color
, you can:
RGBToHSV()
.hsv[2]
, a float with value from 0 to 1.Color
with HSVToColor()
.If you want darker Bitmap
,
PorterDuff.Mode.DARKEN
should work. You just need to calibrate COLOR
value:
private Bitmap getDarkerBitmap(Bitmap src)
{
final int COLOR = 0xAAFFFFFF;
final int WIDTH = src.getWidth();
final int HEIGHT = src.getHeight();
final Bitmap result = Bitmap.createBitmap(WIDTH, HEIGHT, src.getConfig());
final BitmapDrawable drawable = new BitmapDrawable(src);
drawable.setBounds(0, 0, WIDTH, HEIGHT);
drawable.setColorFilter(COLOR, PorterDuff.Mode.DARKEN);
drawable.draw(new Canvas(result));
return result;
}
Simply do this:
int color = ....
int r = Color.red(color);
int b = Color.blue(color);
int g = Color.green(color);
int darkerColor = Color.rgb((int)(r*.9), (int)(g*.9), (int)(b*.9));
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With