Ejemplo n.º 1
0
        private void DrawLineCurveInternal(DrawingContext dc, double half, Pen pen, XLine line, ref Point pt1, ref Point pt2, double dx, double dy)
        {
            double p1x = pt1.X;
            double p1y = pt1.Y;
            double p2x = pt2.X;
            double p2y = pt2.Y;

            XLineExtensions.GetCurvedLineBezierControlPoints(
                line.Style.LineStyle.CurveOrientation,
                line.Style.LineStyle.Curvature,
                line.Start.Alignment,
                line.End.Alignment,
                ref p1x, ref p1y,
                ref p2x, ref p2y);

            PathGeometry pg = _curvedLineCache.Get(line);

            if (pg != null)
            {
                var pf = pg.Figures[0];
                pf.StartPoint = new Point(pt1.X + dx, pt1.Y + dy);
                pf.IsFilled   = false;
                var bs = pf.Segments[0] as BezierSegment;
                bs.Point1    = new Point(p1x + dx, p1y + dy);
                bs.Point2    = new Point(p2x + dx, p2y + dy);
                bs.Point3    = new Point(pt2.X + dx, pt2.Y + dy);
                bs.IsStroked = line.IsStroked;
            }
            else
            {
                var pf = new PathFigure()
                {
                    StartPoint = new Point(pt1.X + dx, pt1.Y + dy),
                    IsFilled   = false
                };
                var bs = new BezierSegment(
                    new Point(p1x + dx, p1y + dy),
                    new Point(p2x + dx, p2y + dy),
                    new Point(pt2.X + dx, pt2.Y + dy),
                    line.IsStroked);
                //bs.Freeze();
                pf.Segments.Add(bs);
                //pf.Freeze();
                pg = new PathGeometry();
                pg.Figures.Add(pf);
                //pg.Freeze();

                _curvedLineCache.Set(line, pg);
            }

            DrawPathGeometryInternal(dc, half, null, pen, line.IsStroked, false, pg);
        }
Ejemplo n.º 2
0
 private static void DrawLineCurveInternal(Graphics gfx, Pen pen, bool isStroked, ref PointF pt1, ref PointF pt2, double curvature, CurveOrientation orientation, PointAlignment pt1a, PointAlignment pt2a)
 {
     if (isStroked)
     {
         double p1x = pt1.X;
         double p1y = pt1.Y;
         double p2x = pt2.X;
         double p2y = pt2.Y;
         XLineExtensions.GetCurvedLineBezierControlPoints(orientation, curvature, pt1a, pt2a, ref p1x, ref p1y, ref p2x, ref p2y);
         gfx.DrawBezier(
             pen,
             pt1.X, pt1.Y,
             (float)p1x,
             (float)p1y,
             (float)p2x,
             (float)p2y,
             pt2.X, pt2.Y);
     }
 }
Ejemplo n.º 3
0
 private void DrawLineCurveInternal(SKCanvas canvas, SKPaint pen, bool isStroked, ref SKPoint pt1, ref SKPoint pt2, double curvature, CurveOrientation orientation, PointAlignment pt1a, PointAlignment pt2a)
 {
     if (isStroked)
     {
         using (var path = new SKPath())
         {
             path.MoveTo(pt1.X, pt1.Y);
             double p1x = pt1.X;
             double p1y = pt1.Y;
             double p2x = pt2.X;
             double p2y = pt2.Y;
             XLineExtensions.GetCurvedLineBezierControlPoints(orientation, curvature, pt1a, pt2a, ref p1x, ref p1y, ref p2x, ref p2y);
             path.CubicTo(
                 (float)p1x,
                 (float)p1y,
                 (float)p2x,
                 (float)p2y,
                 pt2.X, pt2.Y);
             canvas.DrawPath(path, pen);
         }
     }
 }
Ejemplo n.º 4
0
 private static void DrawLineCurveInternal(AM.DrawingContext _dc, AM.Pen pen, bool isStroked, ref A.Point pt1, ref A.Point pt2, double curvature, CurveOrientation orientation, PointAlignment pt1a, PointAlignment pt2a)
 {
     if (isStroked)
     {
         var sg = new AM.StreamGeometry();
         using (var sgc = sg.Open())
         {
             sgc.BeginFigure(new A.Point(pt1.X, pt1.Y), false);
             double p1x = pt1.X;
             double p1y = pt1.Y;
             double p2x = pt2.X;
             double p2y = pt2.Y;
             XLineExtensions.GetCurvedLineBezierControlPoints(orientation, curvature, pt1a, pt2a, ref p1x, ref p1y, ref p2x, ref p2y);
             sgc.CubicBezierTo(
                 new A.Point(p1x, p1y),
                 new A.Point(p2x, p2y),
                 new A.Point(pt2.X, pt2.Y));
             sgc.EndFigure(false);
         }
         _dc.DrawGeometry(null, pen, sg);
     }
 }