public void TestBoundingBoxBezierRectangle() { var curve = new BezierTestData { Matrix = new Matrix { OffsetX = 50, OffsetY = offsetY } } .RoundedRectBezier; ReportPainter.PushPaint(c => { c.SetLineWidth(1); var bb = BezierExtensions.BezierBoundingBox(curve); c.SetColor(Colors.SpringGreen); c.Rectangle(bb); c.Stroke(); c.SetColor(Colors.Blue); c.SetLineWidth(2); ContextPainterExtensions.DrawBezier(c, curve); c.Stroke(); }); WritePainter(); offsetY += 200; }
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(); }
public void TestPaintDocumentNaviatator() { var engine = ReportPainter.Switch(); var bounds = new Rectangle(10, 10, 500, 100); var iconeria = new AwesomeIconeria { Fill = true, FillColor = Colors.Black }; var utils = Registry.Pooled <IDrawingUtils>(); var style = Registry.Pooled <StyleSheets>().DefaultStyleSheet.ItemStyle.DefaultStyle.Clone() as IStyle; // points = pixels * 72 / g.DpiX; style.Font = Font.FromName(style.Font.Family).WithSize((bounds.Height - bounds.Height / 10) * 72 / utils.ScreenResolution().Width); var pageNr = "XXXX"; var pageNrSize = utils.GetTextDimension(pageNr, style); ReportPainter.PushPaint(ctx => { ctx.SetLineWidth(1); ctx.SetColor(Colors.Blue); ContextPainterExtensions.DrawRoundedRect(ctx, bounds, 45); ctx.ClosePath(); ctx.Stroke(); var iconSize = bounds.Height; iconeria.PaintIcon(ctx, iconSize, bounds.X + iconSize / 2, bounds.Y, c => { c.Scale(-1, 1); iconeria.FaPlay(c); }); iconeria.PaintIcon(ctx, iconSize, bounds.Right - ((iconSize * .7)), bounds.Y, c => { iconeria.FaPlay(c); }); var textBounds = new Rectangle(new Point(), pageNrSize); textBounds.Location = new Point( bounds.Location.X + (bounds.Width - textBounds.Width) / 2, bounds.Location.Y + (bounds.Height - textBounds.Height) / 2); ContextPainterExtensions.DrawText(ctx, textBounds, "123", style.Font, style.TextColor); ctx.SetColor(Colors.Aqua); ctx.Rectangle(textBounds); ctx.Stroke(); }); WritePainter(); ReportPainter.Restore(engine); }
private void PaintSegments(IList <Point> curve) { var segments = BezierExtensions.BezierSegments(curve); var cols = new Color[] { Colors.Blue, Colors.Red, Colors.BlueViolet, Colors.OrangeRed, Colors.AliceBlue, Colors.Orange, Colors.Aquamarine, Colors.DodgerBlue }; ReportPainter.PushPaint(c => { var iCol = 0; foreach (var seg in segments) { c.SetLineWidth(1); var bb = BezierExtensions.BezierBoundingBox(seg.Start, seg.Cp1, seg.Cp2, seg.End); c.SetColor(Colors.SpringGreen); c.Rectangle(bb); c.Stroke(); c.SetColor(cols[iCol++]); c.SetLineWidth(2); ContextPainterExtensions.DrawBezier(c, seg); c.Stroke(); var med = BezierExtensions.BezierPoint(seg.Start, seg.Cp1, seg.Cp2, seg.End, .5); c.SetColor(Colors.DarkGray); c.Arc(med.X, med.Y, 5, 0, 360); c.Stroke(); } }); WritePainter(); }
public void TestBezierHull(IList <Point> bezier) { base.ReportPainter.PushPaint(c => { c.SetColor(Colors.Blue); c.SetLineWidth(2); ContextPainterExtensions.DrawBezier(c, bezier); c.Stroke(); }); var cps = BezierExtensions.ControlPoints(bezier); base.ReportPainter.PushPaint(c => { c.SetColor(Colors.Red); c.SetLineWidth(1); foreach (var p in cps) { c.Arc(p.X, p.Y, 5, 0, 360); c.Stroke(); } ; }); var hull = BezierExtensions.BezierHull(bezier); base.ReportPainter.PushPaint(c => { c.SetColor(Colors.Green); c.SetLineWidth(1); foreach (var p in hull) { c.Arc(p.X, p.Y, 3, 0, 360); c.Fill(); } ContextPainterExtensions.DrawPoligon(c, hull); c.Stroke(); }); WritePainter(); }