hiho..
war gerade dabei mir nen Colorpicker zu basteln.. habs auch soweit hinbekommen, nur will entweder a) der PathGradientBrush nich so wie er soll (glaub ich eher weniger) oder b) ist meine Methode Hsv-Farben in Rgb-Farben zu konvertieren falsch...
(in der HsvColor class nimm ich H (0-360), S(0-1f), V(0-1f))
seht ihr was? (methode zum konvertieren):
float h = (color.Hue / 60);
float f = (color.Hue / 60) - h;
float p = color.Value * (1 - color.Saturation);
float q = color.Value * (1 - color.Saturation * f);
float t = color.Value * (1 - color.Saturation * (1 - f));
h %= 6;
switch ((int)h) {
case 0: {
byte r = (byte)(color.Value * 255);
byte g = (byte)(t * 255);
byte b = (byte)(p * 255);
return Color.FromArgb(r, g, b);
}
case 1: {
byte r = (byte)(q * 255);
byte g = (byte)(color.Value * 255);
byte b = (byte)(p * 255);
return Color.FromArgb(r, g, b);
}
case 2: {
byte r = (byte)(p * 255);
byte g = (byte)(color.Value * 255);
byte b = (byte)(t * 255);
return Color.FromArgb(r, g, b);
}
case 3: {
byte r = (byte)(p * 255);
byte g = (byte)(q * 255);
byte b = (byte)(color.Value * 255);
return Color.FromArgb(r, g, b);
}
case 4: {
byte r = (byte)(t * 255);
byte g = (byte)(p * 255);
byte b = (byte)(color.Value * 255);
return Color.FromArgb(r, g, b);
}
case 5: {
byte r = (byte)(color.Value * 255);
byte g = (byte)(p * 255);
byte b = (byte)(q * 255);
return Color.FromArgb(r, g, b);
}
}
return Color.Empty;
und dort wo ich den brush anlege... :
List<PointF> points = new List<PointF>();
List<byte> pathPointType = new List<byte>();
List<Color> colors = new List<Color>();
int angle = 0;
int step = 1;
float r = bounds.Width / 2 - 1;
PointF middle = new PointF(
this.bounds.Left + this.bounds.Width / 2,
this.bounds.Top + this.bounds.Height / 2
);
while (angle < 360) {
PointF pos = middle;
pos.X += (float)(r * Math.Sin(angle * (Math.PI / 180)));
pos.Y -= (float)(r * Math.Cos(angle * (Math.PI / 180)));
points.Add(pos);
pathPointType.Add((byte)PathPointType.Line);
colors.Add(HsvColor.FromHsv(angle, 1, 1).ToRgb());
angle += step;
}
wheelPath = new GraphicsPath(points.ToArray(), pathPointType.ToArray());
wheelPath.CloseAllFigures();
pathBrush = new PathGradientBrush(wheelPath);
pathBrush.CenterColor = Color.White;
pathBrush.CenterPoint = middle;
pathBrush.SurroundColors = colors.ToArray();
hatte schonmal ein bissl durch forum gesucht, doch kamen bei den Lösungen die in anderen threads vorgeschlagen worden zu den gleichen ergebnissen.
aussehen tuts so.. (siehe anhang)