渲染优化

This commit is contained in:
muqing 2024-08-26 07:58:04 +08:00
parent 6a261ecae7
commit 49b462253a

View File

@ -170,6 +170,7 @@ public class Music
var a = chars.GetLength(0);
var b = chars.GetLength(1);
var buffer = new StringBuilder();
ConsoleColor xiantiaoColor = random.Next(0, 2) == 0 ? ConsoleColor.Red : ConsoleColor.Blue;//线条的颜色
while (IsWhile)
{
stopwatch.Restart();
@ -180,7 +181,7 @@ public class Music
{
for (j = 0; j < b; j++)
{
Console.ForegroundColor = chars[i, j].Color;
//Console.ForegroundColor = chars[i, j].Color;
//Console.Write($" {chars[i, j].Char} ");
buffer.Append(chars[i, j].Char);
time++;
@ -192,13 +193,14 @@ public class Music
buffer.AppendLine();
//Console.WriteLine();
}
Console.ForegroundColor = ConsoleColor.DarkBlue;
Console.Write(buffer.ToString());
if (time % 1000 == 0)
{
Console.ForegroundColor = random.Next(0, 2) == 0 ? ConsoleColor.Red : ConsoleColor.Blue;
xiantiaoColor= random.Next(0, 2) == 0 ? ConsoleColor.Red : ConsoleColor.Blue;
}
// Console.ForegroundColor = (ConsoleColor)random.Next(0, 16);
Console.ForegroundColor = xiantiaoColor;
for (i = 0; i < b; i++)
{
@ -218,8 +220,8 @@ public class Music
// 保持每秒约16.67ms即大约60 FPS的间隔
// Thread.Sleep(Math.Max(0, 60 - (int)elapsedMilliseconds));
//死方法 不知道为什么 控制台限制60 帧这样闪烁不会太严重
Thread.Sleep(150);
//这样闪烁不会太严重
Thread.Sleep(100);
}
}
private void setCharArry()