Пример #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="WordCloud"/> class.
        /// </summary>
        /// <param name="width">The width of word cloud.</param>
        /// <param name="height">The height of word cloud.</param>
        /// <param name="useRank">if set to <c>true</c> will ignore frequencies for best fit.</param>
        /// <param name="fontColor">Color of the font.</param>
        /// <param name="maxFontSize">Maximum size of the font.</param>
        /// <param name="fontStep">The font step to use.</param>
        public WordCloud(int width, int height, bool useRank = false, Color?fontColor = null, int maxFontSize = -1,
                         int fontStep = 1)
        {
            Map   = new OccupancyMap(width, height);
            Image = new FastImage(width, height, PixelFormat.Format32bppArgb);

            MaxFontSize = maxFontSize < 0 ? height : maxFontSize;
            FontStep    = fontStep;
            m_fontColor = fontColor;
            UseRank     = useRank;
            Random      = new Random();
        }
Пример #2
0
        public void Update(FastImage image, int posX, int posY)
        {
            if (posX < 1)
            {
                posX = 1;
            }
            if (posY < 1)
            {
                posY = 1;
            }

            for (int i = posY; i < image.Height; ++i)
            {
                for (int j = posX; j < image.Width; ++j)
                {
                    byte pixel = 0;
                    for (int p = 0; p < image.PixelFormatSize; ++p)
                    {
                        pixel |= image.Data[i * image.Stride + j * image.PixelFormatSize + p];
                    }
                    Integral[j, i] = pixel + Integral[j - 1, i] + Integral[j, i - 1] - Integral[j - 1, i - 1];
                }
            }
        }
Пример #3
0
 public void Update(FastImage image)
 {
     Update(image, 1, 1);
 }