UNITY C#如何将颜色渐变循环
我想做一个七种颜色渐变的灯光效果,那么一种的渐变效果我做出来了但颜色到了[1]如何再渐变到[2]以此类推呢?求方法publicColor[]colorstar;voidU...
我想做一个七种颜色渐变的灯光效果,那么一种的渐变效果我做出来了
但颜色到了[1]如何再渐变到[2] 以此类推呢?求方法
public Color[] colorstar;
void Update () {
float colorlerp = Mathf.MoveTowards (0, 1,0.1f * Time.time);
Lightcolor.color = Color.Lerp (colorstar[0],colorstar[1], colorlerp);
} 展开
但颜色到了[1]如何再渐变到[2] 以此类推呢?求方法
public Color[] colorstar;
void Update () {
float colorlerp = Mathf.MoveTowards (0, 1,0.1f * Time.time);
Lightcolor.color = Color.Lerp (colorstar[0],colorstar[1], colorlerp);
} 展开
2个回答
展开全部
//说明:RGB为光的红绿蓝三原色,(每一种颜色范围0~255)通过改变三种颜色的比例即可调出各种颜色
private void btn_Color_Click(object sender, EventArgs e)
{
Thread t = new Thread(Update);
t.IsBackground = true;
t.Start();
}
new void Update()
{
int i = 0, j = 100, k = 100;
//变红
for (i=100; i<255; i = i + 5)
{
Color c = Color.FromArgb(i, j, k);
label4.BackColor = c;
Thread.Sleep(100);
}
//变绿
for (j =100; j < 255; j += 5)
{
i = 100; k = 100;
Color c = Color.FromArgb(i, j, k);
label4.BackColor = c;
Thread.Sleep(100);
}
//变蓝
for (k = 100; k < 255; k += 5)
{
i = 100; j = 100;
Color c = Color.FromArgb(i, j, k);
label4.BackColor = c;
Thread.Sleep(100);
}
MessageBox.Show("色彩展示1完毕");
//彩虹渐变
for (i = 0; i < 125;i++ )
{
Color c = Color.FromArgb(255-2*i, i, 2*i);
label4.BackColor = c;
Thread.Sleep(200);
}
MessageBox.Show("色彩展示2完毕");
}
展开全部
//说明:RGB为光的红绿蓝三原色,(每一种颜色范围0~255)通过改变三种颜色的比例即可调出各种颜色
private void btn_Color_Click(object sender, EventArgs e)
{
Thread t = new Thread(Update);
t.IsBackground = true;
t.Start();
}
new void Update()
{
int i = 0, j = 100, k = 100;
//变红
for (i=100; i<255; i = i + 5)
{
Color c = Color.FromArgb(i, j, k);
label4.BackColor = c;
Thread.Sleep(100);
}
//变绿
for (j =100; j < 255; j += 5)
{
i = 100; k = 100;
Color c = Color.FromArgb(i, j, k);
label4.BackColor = c;
Thread.Sleep(100);
}
//变蓝
for (k = 100; k < 255; k += 5)
{
i = 100; j = 100;
Color c = Color.FromArgb(i, j, k);
label4.BackColor = c;
Thread.Sleep(100);
}
MessageBox.Show("色彩展示1完毕");
//彩虹渐变
for (i = 0; i < 125;i++ )
{
Color c = Color.FromArgb(255-2*i, i, 2*i);
label4.BackColor = c;
Thread.Sleep(200);
}
MessageBox.Show("色彩展示2完毕");
}
private void btn_Color_Click(object sender, EventArgs e)
{
Thread t = new Thread(Update);
t.IsBackground = true;
t.Start();
}
new void Update()
{
int i = 0, j = 100, k = 100;
//变红
for (i=100; i<255; i = i + 5)
{
Color c = Color.FromArgb(i, j, k);
label4.BackColor = c;
Thread.Sleep(100);
}
//变绿
for (j =100; j < 255; j += 5)
{
i = 100; k = 100;
Color c = Color.FromArgb(i, j, k);
label4.BackColor = c;
Thread.Sleep(100);
}
//变蓝
for (k = 100; k < 255; k += 5)
{
i = 100; j = 100;
Color c = Color.FromArgb(i, j, k);
label4.BackColor = c;
Thread.Sleep(100);
}
MessageBox.Show("色彩展示1完毕");
//彩虹渐变
for (i = 0; i < 125;i++ )
{
Color c = Color.FromArgb(255-2*i, i, 2*i);
label4.BackColor = c;
Thread.Sleep(200);
}
MessageBox.Show("色彩展示2完毕");
}
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询