I have created a multiple Color gradient on Windows Form panel. Now I want to get color in specific location.
Updated:
I am working on a correlation matrix where the data values will be in range of 1 and -1. E.g 1, 0.99, -0.33, and -1 etc. I don't want to use hard coded colors values because user wants to create his own colors patterns. These color patterns will be saved in database.
private void panel_Paint(object sender, PaintEventArgs e)
{
var clientRectangle = new Rectangle(0, 0, 200, 200);
LinearGradientBrush br = new LinearGradientBrush(clientRectangle, Color.Green, Color.Red,
LinearGradientMode.Horizontal);
ColorBlend cb = new ColorBlend();
cb.Positions = new[] { 0, 0.5f, 1 };
cb.Colors = new[] { Color.Green, Color.Yellow, Color.Red };
br.InterpolationColors = cb;
e.Graphics.FillRectangle(br, clientRectangle);
}
I have searched on it but can't find the solution. How can I get?
Thank you