コード例 #1
0
        public void CreateBitmapWithWords(IEnumerable <string> text, string path)
        {
            var stats = Preprocessor.Processing(text);

            DeterminatorOfWordSize.SetParameters(stats);
            CloudLayouter.SetCloudSetting(Settings.Width, Settings.Height, Settings.CenterPoint);
            var words = stats.Select(tuple => new WordInformation(tuple.Key, tuple.Value)).OrderByDescending(x => x.Frequency);

            Bitmap   bitmap = new Bitmap(Settings.Width, Settings.Height);
            Graphics g      = Graphics.FromImage(bitmap);

            g.Clear(Settings.BackgroundColor);
            foreach (var wordInformation in words)
            {
                var font    = DeterminatorOfWordSize.GetFont(wordInformation, Settings.Fontname);
                var size    = g.MeasureString(wordInformation.Content, font);
                var bigSize = new Size((int)Math.Ceiling(size.Width), (int)Math.Ceiling(size.Height));
                if (!CloudLayouter.TryPutNextRectangle(bigSize))
                {
                    break;
                }
                var rectangle = CloudLayouter.LastPlacedRectangle;
                g.TextRenderingHint = System.Drawing.Text.TextRenderingHint.ClearTypeGridFit;
                g.DrawString(wordInformation.Content, font,
                             new SolidBrush(Settings.AlgorithmOfColoringWords.GetColor(wordInformation, Settings.Colors)), rectangle);
            }

            CloudLayouter.RemovePlacedRectangles();
            bitmap.Save(path, Settings.ImageFormat);
        }
コード例 #2
0
        public void InitializeTests()
        {
            center = new Point(1000, 1000);
            var spiral = new ArchimedesSpiral(center);

            cloudLayouter = new CloudLayouter(spiral);
        }
コード例 #3
0
ファイル: CloudLayouterTests.cs プロジェクト: PShenica/di
        public void SetUp()
        {
            const double distanceBetweenLoops = 0.2;
            const double angleDelta           = 1;

            RectangleVisualizer = new RectangleVisualizer();
            Center = new Point(300, 300);
            Sut    = new CloudLayouter(new ArchimedeanSpiral(Center, distanceBetweenLoops, angleDelta));
        }
コード例 #4
0
        public void NextRectangleMustByFartherFromCenter(IEnumerable <Size> rectanglesSizes)
        {
            var center       = new Point(0, 0);
            var cloud        = new CloudLayouter(new ArchimedesSpiral(center));
            var lastDistance = 0.0;

            foreach (var rectangleSize in rectanglesSizes)
            {
                var rectangle = cloud.PutNextRectangle(rectangleSize).GetValueOrThrow();
                var distance  = rectangle.GetDistanceToPoint(center);
                distance.Should().BeGreaterOrEqualTo(lastDistance);

                lastDistance = distance;
            }
        }
コード例 #5
0
ファイル: CircularCloudTests.cs プロジェクト: finkrer/fp
        public void Constructor_ShouldCreateLayouterWithCenter()
        {
            var layouter = new CloudLayouter(strategies);

            layouter.Center.Should().Be(new Point(0, 0));
        }
コード例 #6
0
ファイル: CircularCloudTests.cs プロジェクト: finkrer/fp
        public void SetUp()
        {
            var point = new Point(0, 0);

            layouter = new CloudLayouter(strategies);
        }
コード例 #7
0
 public void CreateNewLayouter_WhenPointIsPassed()
 {
     layouter = new CloudLayouter(new Point(20, 20), 1);
 }
コード例 #8
0
 public void SetUp()
 {
     layouter = new CloudLayouter(new Point(20, 20), 1);
 }