本文整理汇总了C#中RGB.Set方法的典型用法代码示例。如果您正苦于以下问题:C# RGB.Set方法的具体用法?C# RGB.Set怎么用?C# RGB.Set使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类RGB
的用法示例。
在下文中一共展示了RGB.Set方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Window_Loaded
private void Window_Loaded(object sender, RoutedEventArgs eventArgs)
{
#if DISP_ASTAR_LSTAR
// a*L*平面。L軸は0~100なので
float originOffsetX = 400;
float originOffsetY = 800;
labelAxisA.Content = "a*→";
labelAxisA.Margin = new Thickness(700, 200, 0, 0);
labelAxisB.Content = "↑L*";
labelAxisB.Margin = new Thickness(400, 100, 0, 0);
labelOrigin.Margin = new Thickness(400, 766, 0, 0);
#else
// a*b*平面
float originOffsetX = 400;
float originOffsetY = 400;
labelAxisA.Content = "a*";
labelAxisA.Margin = new Thickness(763, 400, 0, 0);
labelAxisB.Content = "b*";
labelAxisB.Margin = new Thickness(400, 6, 0, 0);
labelOrigin.Margin = new Thickness(400, 400, 0, 0);
#endif
rectangleV.Height = canvas1.Height;
rectangleV.Margin = new Thickness(originOffsetX, 0, 0, 0);
rectangleH.Width = canvas1.Width;
rectangleH.Margin = new Thickness(0, originOffsetY, 0, 0);
var rgbHash = new HashSet<int>();
var colors = new List<ColorPatch>[SEGMENT_NUM];
for (int i = 0; i < SEGMENT_NUM; ++i) {
colors[i] = new List<ColorPatch>();
}
for (int i = 0; i < colorTable.Length / 3; ++i) {
byte r = colorTable[i * 3];
byte g = colorTable[i * 3 + 1];
byte b = colorTable[i * 3 + 2];
var c = Color.FromRgb(r, g, b);
RGB rgb = new RGB();
rgb.Set(r, g, b);
LabStar lab = XYZtoLabStar(RGBtoXYZ(rgb));
var cp = new ColorPatch();
cp.id = i;
cp.rgb = rgb;
cp.lab = lab;
colors[i / COLOR_NUM_PER_SEGMENT].Add(cp);
Ellipse e = new Ellipse();
e.Fill = new SolidColorBrush(c);
e.Height = 16;
e.Width = 16;
#if DISP_ASTAR_LSTAR
// a*L*平面
var pos = new Thickness((lab.a) * 10 + originOffsetX, (-lab.L) * 10 + originOffsetY, 0, 0);
#else
// a*b*平面
var pos = new Thickness((lab.a) * 10 + originOffsetX, (-lab.b) * 10 + originOffsetY, 0, 0);
#endif
e.Margin = pos;
canvas1.Children.Add(e);
Canvas.SetZIndex(e, -1);
bool collision = false;
int hashValue = r * 65536 + g * 256 + b;
if (rgbHash.Contains(hashValue)) {
collision = true;
}
rgbHash.Add(hashValue);
Label l = new Label();
l.Content = string.Format("{0}", i + 1);
l.FontSize = 8;
l.Foreground = new SolidColorBrush(Colors.White);
l.Margin = pos;
if (collision) {
l.Margin = new Thickness(pos.Left, pos.Top + l.FontSize, pos.Right, pos.Bottom);
}
canvas1.Children.Add(l);
}
for (int segment = 0; segment < SEGMENT_NUM; ++segment) {
for (int i = 0; i < COLOR_NUM_PER_SEGMENT; ++i) {
var cpFrom = colors[segment].ElementAt(i);
var cpSort = new Dictionary<float, ColorPatch>();
for (int j = 0; j < COLOR_NUM_PER_SEGMENT; ++j) {
if (i == j) {
continue;
}
var cpTo = colors[segment].ElementAt(j);
cpSort.Add(cpFrom.lab.DistanceSquared(cpTo.lab), cpTo);
}
//.........这里部分代码省略.........