- Home /
Question by
unity_7c3Dc2K7ApRKfQ · Jan 18, 2018 at 10:59 AM ·
c#xmlexcel
Create a lighter/darker color based on a OpenXml color
How to get HEX value of Excel theme colors (e.g. Accent6, Darker25%) using OpenXML? I have tried following code:
public static System.Drawing.Color ChangeColorHexValue(System.Drawing.Color color, float tintsValue)
{
float red = (float)color.R;
float green = (float)color.G;
float blue = (float)color.B;
if (tintsValue < 0)
{
tintsValue = 1 + tintsValue;
red *= tintsValue;
green *= tintsValue;
blue *= tintsValue;
}
else
{
red = (255 - red) * tintsValue + red;
green = (255 - green) * tintsValue + green;
blue = (255 - blue) * tintsValue + blue;
}
return System.Drawing.Color.FromArgb(color.A, (int)red, (int)green, (int)blue);
}
Comment
Answer by Harinezumi · Jan 18, 2018 at 11:28 AM
I'm not exactly sure what you would like to achieve, but to correctly darken a color a certain percent I would convert it to HSV space, change the V value as required, and then convert back. Here is an open source HSV color implementation for Unity: https://gist.github.com/cjddmut/fefe5dac35cccfceabec
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Distribute terrain in zones 3 Answers
Illuminating a 3D object's edges OnMouseOver (script in c#)? 1 Answer
How do I use this XML reader? 1 Answer
Extract C# code from XML file 1 Answer