private static void BuildDiversityMap(List <List <Vector2> > allComps, out List <Color[, ]> resColor,
                                              out List <int[, ]> resCountInBox, out List <float[, ]> resPerc)
        {
            resColor      = new List <Color[, ]>();
            resCountInBox = new List <int[, ]>();
            resPerc       = new List <float[, ]>();
            int counterComp = 0;

            foreach (List <Vector2> compPositions in allComps)
            {
                int compCount = compPositions.Count;
                Color[,] colorArr = new Color[3, 3];
                int[,] intArr     = new int[3, 3];
                float[,] percArr  = new float[3, 3];

                for (int i = 0; i < colorArr.GetLength(0); i++)
                {
                    for (int j = 0; j < colorArr.GetLength(1); j++)
                    {
                        Rectangle cellBox    = GetCellBox(i, j);
                        int       countInBox = compPositions.Count(c => InsideBox(c, cellBox));
                        float     perc       = countInBox / (compCount / (float)5);
                        colorArr[i, j] = ControlPaint.Light(GetColor(counterComp), 1 - perc);
                        intArr[i, j]   = countInBox;
                        percArr[i, j]  = perc;
                    }
                }
                resColor.Add(colorArr);
                resCountInBox.Add(intArr);
                resPerc.Add(percArr);
                counterComp++;
            }
        }
Beispiel #2
0
        public static Bitmap ColorMatrixToBitmap(Color[,] colors)
        {
            var width = colors.GetLength(0);
            var height = colors.GetLength(1);

            var img = new Bitmap(width, height);

            for (int i = 0; i < width; i++)
            {
                for (int j = 0; j < height; j++)
                {
                    img.SetPixel(i, j, colors[i,j]);
                }
            }

            return img;
        }
Beispiel #3
0
 public UUID SaveBitmap(Color[,] data, bool lossless, bool temporary)
 {
     Bitmap image = new Bitmap(data.GetLength(0), data.GetLength(1));
     for (int x = 0; x < image.Width; x++)
         for (int y = 0; y < image.Height; y++)
             image.SetPixel(x, y, data[x, y]);
     return SaveBitmap(image, lossless, temporary);
 }