public static Rectangle GetCircumscribedSquare(this CircularCloudLayoutCreator layoutCreator) { var width = Math.Max(Math.Abs(layoutCreator.GetMinXCoordinate() - layoutCreator.GetMinXCoordinate()), Math.Abs(layoutCreator.GetMaxYCoordinate() - layoutCreator.GetMinYCoordinate())); var height = width; return(new Rectangle(layoutCreator.Center.X - width / 2, layoutCreator.Center.Y - height / 2, width, height)); }
public new void SetUp() { CloudLayoutCreator = new CircularCloudLayoutCreator( new CircularCLoudLayouterSettings(TestingDegenerateSize.CenterPoint, 0.5)); tiledRectangles = Enumerable .Range(0, ElementsAmount) .Select(number => CloudLayoutCreator.PutNextRectangle(TestingDegenerateSize.SingleSize)) .ToList(); }
public void Should_LocateFirstRectangleCenter_OnSpecifiedPoint(Point center) { var layoutCreator = new CircularCloudLayoutCreator(new CircularCLoudLayouterSettings(center, 1)); var rect = layoutCreator.PutNextRectangle(new Size(2, 2)); (rect.X + rect.Width / 2) .Should() .Be(center.X, "X coords not equal"); (rect.Y + rect.Height / 2) .Should() .Be(center.Y, "X coords not equal"); }
public Drawer(Size imgSize) { stringFormat = new StringFormat { LineAlignment = StringAlignment.Center, Alignment = StringAlignment.Center }; brush = Brushes.Bisque; layoutCreator = new CircularCloudLayoutCreator( new CircularCLoudLayouterSettings( new Point(imgSize.Width / 2, imgSize.Height / 2), 1)); bitmap = new Bitmap(imgSize.Width, imgSize.Height); Graphics.FromImage(bitmap).Clear(Color.Black); }
public void Should_CreateCircleShape_With1000RandomGeneratedRectangles(string fileName) { var cloudLayoutCreator = new CircularCloudLayoutCreator(new CircularCLoudLayouterSettings(new Point(600, 600), 1)); var rnd = new Random(); OnFailDrawer.DrawOriginOrientedRectangles( new Size(1200, 1200), Enumerable .Range(0, 100) .Select(num => new Size(rnd.Next(30, 100), rnd.Next(30, 100))) .Select(size => cloudLayoutCreator.PutNextRectangle(size)), fileName ); }
public void SetUp() { CloudLayoutCreator = new CircularCloudLayoutCreator( new CircularCLoudLayouterSettings(TestingDegenerateSize.CenterPoint, 1)); }
private static int GetMaxYCoordinate(this CircularCloudLayoutCreator layoutCreator) { return(layoutCreator.GetAllRectangles().Max(r => r.Y + r.Height)); }