public void LoadImage(string path, Vector2 position, char c = 'X') { Bitmap img = new Bitmap(@path); for (int j = 0; j < img.Height; j++) { for (int i = 0; i < (img.Width * 2); i++) { Color pixel = img.GetPixel(i / 2, j); string color = ColorHandler.ClosestConsoleColor(pixel.R, pixel.G, pixel.B).ToString().ToUpper(); SetPixel(new Vector2(i + position.x, j + position.y), c, color, color); } } }
public void Draw(bool overwrite = true) { Vector2 position = new Vector2(_cameraPosition.x, _cameraPosition.y); int CursorPosY = Console.CursorTop; if (CursorPosY >= _windowSize.y) { CursorPosY -= _windowSize.y; } if (overwrite) { Console.SetCursorPosition(0, CursorPosY); } while (position.y - _cameraPosition.y < _windowSize.y) { while (position.x - _cameraPosition.x <= _windowSize.x) { for (int i = 0; i <= (pixels.Count - 1); i++) { if (pixels[i].position.x == position.x && pixels[i].position.y == position.y) { ColorHandler.SetConsoleColor(pixels[i].backGroundColor, pixels[i].foreGroundColor); Console.Write(pixels[i].character); ColorHandler.SetConsoleColor(defaultBackgroundColor, defaultForeGroundColor); break; } else if (i == (pixels.Count - 1)) { Console.Write(_character); } } position.x++; } Console.WriteLine(); position.x = _cameraPosition.x; position.y++; } }