Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Convert a colour to a darker shade in Xamarin

I have a colour picker that allows my Xamarin app to set a theme colour. I want to calculate a darker shade of the same colour to identify different items.

How can I calculate a darker shade from a colour?

like image 792
RaKer Avatar asked Mar 04 '23 11:03

RaKer


1 Answers

Assuming this is a Forms' Color, you can use the WithLuminosity method to decrease its "brightness" value and return a new darker color.

Example:

var color = label.BackgroundColor;
var newColor = color.WithLuminosity(color.Luminosity - (color.Luminosity * .1));
label.BackgroundColor = newColor;
like image 68
SushiHangover Avatar answered Mar 18 '23 11:03

SushiHangover