public void Render(ref AnsiConsole console) { ReadOnlySpan <char> frame = NyancatFrames.GetFrame(_fc); var lastPixel = char.MinValue; for (var row = _minRow; row < _maxRow; ++row) { for (var col = _minCol; col < _maxCol; ++col) { char pixel; if (row > 23 && row < 43 && col < 0) { int mod_x = ((-col + 2) % 16) / 8; if ((_fc / 2) % 2 == 0) { mod_x = 1 - mod_x; } var index = mod_x + row - 23; pixel = ','; if (index < RAINBOW_TAIL.Length) { pixel = RAINBOW_TAIL[index]; } } else if (row < 0 || col < 0 || row >= NyancatFrames.FRAME_HEIGHT || col >= NyancatFrames.FRAME_WIDTH) { pixel = ','; } else { var start = row * NyancatFrames.FRAME_WIDTH + (row * 1); start += col; pixel = frame.Slice(start, 1)[0]; } if (!console.SupportsColors()) { console.Write(pixel); console.Write(pixel); } else if (pixel != lastPixel) { var color = AsciiPixelToColor(pixel); console.WriteColor(' ', color); console.Write(' '); } else { console.Write(' '); console.Write(' '); } } console.Write("\x1b[K"); console.WriteLine(); } if (_showCounter == 1) { var totalTime = (Environment.TickCount64 - _startTime) / 1000; var message = string.Concat("You have nyaned for ", totalTime, " seconds!"); var spacesLength = (_width - message.Length) / 2; if (spacesLength > 0) { for (var i = 0; i < spacesLength; i++) { console.Write(console.SupportsColors() ? ' ' : ','); } console.WriteColor(message, Color.White, foreground: true); console.WriteLine("\x1b[J\x1b[0m"); } } }
public void Render(ref ConsoleGraphics console) { ReadOnlySpan <char> frame = NyancatFrames.GetFrame(_fc); var lastPixel = char.MinValue; for (var row = _minRow; row < _maxRow; ++row) { for (var col = _minCol; col < _maxCol; ++col) { char pixel; if (row > 23 && row < 43 && col < 0) { int mod_x = ((-col + 2) % 16) / 8; if ((_fc / 2) % 2 == 0) { mod_x = 1 - mod_x; } var index = mod_x + row - 23; pixel = ','; if (index < RAINBOW_TAIL.Length) { pixel = RAINBOW_TAIL[index]; } } else if (row < 0 || col < 0 || row >= NyancatFrames.FRAME_HEIGHT || col >= NyancatFrames.FRAME_WIDTH) { pixel = ','; } else { var start = row * NyancatFrames.FRAME_WIDTH + (row * 1); start += col; pixel = frame.Slice(start, 1)[0]; } if (ConsoleColorSupport.Level == ColorSupportLevel.None) { lastPixel = pixel; console.Write(_colors[pixel]); console.Write(_colors[pixel]); } else if (pixel != lastPixel && _colors.ContainsKey(pixel)) { lastPixel = pixel; console.Write(_colors[pixel]); console.Write(' '); console.Write(' '); } else { console.Write(' '); console.Write(' '); } } console.Write("\x1b[K"); console.WriteLine(); } if (_showCounter == 1) { var totalTime = (Environment.TickCount64 - _startTime) / 1000; var message = string.Concat("You have nyaned for ", totalTime, " seconds!"); var spacesLength = (_width - message.Length) / 2; if (spacesLength > 0) { for (var i = 0; i < spacesLength; i++) { console.Write(ConsoleColorSupport.Level == ColorSupportLevel.None ? ',' : ' '); } console.ColorBrightWhite(); console.Write(message); console.WriteLine("\x1b[J\x1b[0m"); } } }