public void BezierTest() { var shape = new BezierRectangleShape(); var size = new Size(10.5, 10.5); var location = new Point(5.55, 6.66); shape.Location = location; shape.Size = size; Assert.AreEqual(shape.Size, size); var shapeSize = shape.Size; Assert.AreEqual(location, shape.Location); Assert.AreEqual(shapeSize, shape.Size); location = new Point(4.55, 5.66); shape.Location = location; Assert.AreEqual(location, shape.Location); Assert.AreEqual(shapeSize, shape.Size); size += new Size(1d / 3d, 1d / 3d); shape.Size = size; Assert.AreEqual(shape.Size, size); size = Size.Zero; shape.Size = size; Assert.AreEqual(shape.Size, size); }
public void TestBezierRectJitterAndOffset() { var jitter = 5d; var rect = new Rectangle(0, 0, 400, 100); Action prove = () => { var shape = new BezierRectangleShape(rect) { Jitter = jitter }; var bb = BezierExtensions.BezierBoundingBox(shape.BezierPoints); var offset = bb.Size - rect.Size; ReportDetail("{0} {1} W={2:0.####} H={3}", rect, jitter, offset.Width, offset.Height); }; ReportDetail("************* same jitter, rect growing"); for (int i = 100; i < 10000; i += 100) { rect = new Rectangle(0, 0, i * 3, i); prove(); } ReportDetail("************* same rect, jitter growing"); rect = new Rectangle(0, 0, 400, 100); for (int i = 1; i < rect.Size.Height; i += 5) { jitter = i; prove(); } }
public void TestBezierRectangleShapeResize() { var rect = new Rectangle(10, 10, 200, 100); var shape = new BezierRectangleShape(rect); ReportPainter.PushPaint(c => { c.SetLineWidth(1); c.SetColor(Colors.Red); c.Rectangle(shape.Data); c.Stroke(); c.SetColor(Colors.Blue); ContextPainterExtensions.DrawBezier(c, shape.BezierPoints); c.Stroke(); c.SetColor(Colors.Yellow); c.Rectangle(shape.BoundsRect); c.Stroke(); }); Action <Point, Size> prove = (l, s) => { Assert.AreEqual(shape.BoundsRect.Location, shape.Location); Assert.AreEqual(shape.BoundsRect.Size, shape.Size); Assert.AreEqual(shape.DataSize, shape.Data.Size); Assert.AreEqual(l, shape.Location); Assert.AreEqual(s, shape.Size); }; Assert.AreEqual(shape.DataSize, rect.Size); prove(shape.BoundsRect.Location, shape.BoundsRect.Size); Action <Rectangle> proveResize = (r) => { var reset = shape.Data; var resetBounds = shape.BoundsRect; shape.Location = r.Location; prove(r.Location, shape.Size); shape.Size = r.Size; prove(r.Location, r.Size); shape.Data = reset; prove(resetBounds.Location, resetBounds.Size); shape.Location = r.Location; shape.Size = r.Size; prove(r.Location, r.Size); }; var resize = shape.BoundsRect.Inflate(3, 3); proveResize(resize); resize = shape.BoundsRect.Inflate(-7, -7); proveResize(resize); WritePainter(); }