Ejemplo n.º 1
0
 public void SetCanvas(RgbCanvas canvas)
 {
     for (int y = 0; y < Height; y++)
     {
         for (int x = 0; x < Width; x++)
         {
             Console.ForegroundColor = canvas.GetPixel(x, y).ToConsoleColor();
             Console.Write(".");
         }
         Console.WriteLine();
     }
 }
Ejemplo n.º 2
0
        public void SetCanvasAt(int x, int y, RgbCanvas canvas)
        {
            if (!Validate.InRange(x, y, Width, Height))
            {
                return;
            }

            for (int xOff = x; xOff < Math.Min(Width, canvas.Width); xOff++)
            {
                for (int yOff = y; yOff < Math.Min(Height, canvas.Height); yOff++)
                {
                    SetPixel(xOff, yOff, canvas.GetPixel(xOff - x, yOff - y));
                }
            }
        }
Ejemplo n.º 3
0
        public void SetCanvas(RgbCanvas canvas)
        {
            if (Width != canvas.Width || Height != canvas.Height)
            {
                throw new ArgumentException("RgbCanvas must be same size as RgbMatrix", nameof(canvas));
            }

            for (int x = 0; x < Width; x++)
            {
                for (int y = 0; y < Height; y++)
                {
                    SetPixel(x, y, canvas.GetPixel(x, y));
                }
            }
        }
Ejemplo n.º 4
0
        public static RgbCanvas FromBytes(int width, int height, byte[] bytes)
        {
            if (width * height * 3 != bytes.Length)
            {
                throw new ArgumentException($"width {width} and height {height} and 3 colors per pixel don't match bytes length {bytes.Length}");
            }

            var canvas = new RgbCanvas(width, height);

            for (int y = 0; y < height; y++)
            {
                for (int x = 0; x < width; x++)
                {
                    int startOffset = (y * width * 3) + (x * 3);
                    var color       = new RgbColor(bytes[startOffset], bytes[startOffset + 1], bytes[startOffset + 2]);
                    canvas.SetPixel(x, y, color);
                }
            }

            return(canvas);
        }
Ejemplo n.º 5
0
 public void SetPartialCanvasAt(int targetX, int targetY, RgbCanvas canvas, int sourceX, int sourceY, int sourceWidth,
                                int targetWidth)
 {
     throw new NotImplementedException();
 }
Ejemplo n.º 6
0
 public void SetPartialCanvasAt(int targetX, int targetY, RgbCanvas canvas, int sourceX, int sourceY, int sourceWidth,
                                int targetWidth)
 {
 }
Ejemplo n.º 7
0
 public void SetCanvasAt(int x, int y, RgbCanvas canvas)
 {
 }