StdPaint.ConsoleBuffer.SetUnitBackColor C# (CSharp) Method

SetUnitBackColor() public method

Sets the background color for a specific unit in the buffer.
public SetUnitBackColor ( Point point, BufferColor color ) : void
point Point The location of the unit.
color BufferColor The background color to set the unit to.
return void
        public void SetUnitBackColor(Point point, BufferColor color)
        {
            if (!InBounds(ref point)) return;
            _buffer[point.Y, point.X].BackColor = color;
        }

Same methods

ConsoleBuffer::SetUnitBackColor ( int x, int y, BufferColor color ) : void

Usage Example

Esempio n. 1
0
 private static ConsoleBuffer createBuffer(Bitmap image)
 {
     ConsoleBuffer buffer = new ConsoleBuffer(image.Width, image.Height);
     for (int i = 0; i < image.Width; i++)
         for (int j = 0; j < image.Height; j++)
         {
             Color c = image.GetPixel(i, j);
             if (c.A == 0) continue;
             double[,] distances = new double[16, 2];
             double smallestDistance = -1;
             int smallestKey = 0;
             for (var k = 0; k < 16; k++)
             {
                 // euclidean distance between colors
                 double distance = (double)Math.Sqrt(Math.Pow(c.R - Colors[k, 0], 2) + Math.Pow(c.G - Colors[k, 1], 2) + Math.Pow(c.B - Colors[k, 2], 2));
                 if (smallestDistance > distance || smallestDistance == -1)
                 {
                     smallestDistance = distance;
                     smallestKey = k;
                 }
             }
             buffer.SetUnitBackColor(i, j, (BufferColor)Enum.GetValues(typeof(BufferColor)).GetValue(smallestKey));
         }
     return buffer;
 }
All Usage Examples Of StdPaint.ConsoleBuffer::SetUnitBackColor