gpt4 book ai didi

C#反色

转载 作者:太空宇宙 更新时间:2023-11-03 22:20:17 26 4
gpt4 key购买 nike

<分区>

Possible Duplicate:
How do I invert a colour?

是否可以为给定的 rgb 组合找到相反的颜色?例如,我在一个基本应用程序中有以下内容。

    myColor red = new myColor(0, true), green = new myColor(0, true), blue = new myColor(0, true), theColor;
Random rand = new Random(DateTime.Now.Millisecond);
int color = 0;
void timer_Tick(object sender, EventArgs e)
{
switch (color)
{
case 0: theColor = red; break;
case 1: theColor = green; break;
case 2: theColor = blue; break;
}

if (theColor.Up)
{
theColor.Value += 0.01F;
if (theColor.Value + 0.01F > 1) { theColor.Up = false; color = rand.Next(3); }
}
else if (!theColor.Up)
{
theColor.Value -= 0.01F;
if (theColor.Value - 0.01F < 0) { theColor.Up = true; color = rand.Next(3); }
}
label1.Text = red.Value + Environment.NewLine + green.Value + Environment.NewLine + blue.Value;
FadeBackground(red.Value, green.Value, blue.Value);
}
void FadeBackground(float red, float green, float blue)
{
BackColor = Color.FromArgb((int)((1 - red) * 255), (int)((1 - green) * 255), (int)((1 - blue) * 255));
label1.ForeColor = BackColor;
//label1.BackColor;
}
class myColor
{
public myColor(float value, bool up)
{
Value = value;
Up = up;
}
public float Value;
public bool Up;
}

但我希望能够更改标签的背景颜色,使其始终与背景颜色相反或相反。

在此先感谢,我希望这是有道理的。

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com