private void DrawTransData(IBezierDrawContext context) { context.DrawLines(Color.Black, new PointF[] { transBeziers.TransformRectange.TopLeft, transBeziers.TransformRectange.TopRight, transBeziers.TransformRectange.BottomRight, transBeziers.TransformRectange.BottomLeft, transBeziers.TransformRectange.TopLeft }); DrawSquare(transBeziers.TransformRectange.TopLeft, context); DrawSquare(transBeziers.TransformRectange.TopRight, context); DrawSquare(transBeziers.TransformRectange.BottomLeft, context); DrawSquare(transBeziers.TransformRectange.BottomRight, context); DrawSquare(transBeziers.TransformRectange.TopMiddle, context); DrawSquare(transBeziers.TransformRectange.LeftMiddle, context); DrawSquare(transBeziers.TransformRectange.RightMiddle, context); DrawSquare(transBeziers.TransformRectange.BottomMiddle, context); PointF center = transBeziers.TransformRectange.Center; context.DrawEllipse(Color.Black, new RectangleF { X = center.X - 3, Width = 6, Y = center.Y - 3, Height = 6 }); BezierControlPoint previous = null; foreach (BezierControlPoint bcp in transBeziers.BCPS) { if (previous != null) { if (previous.ValidThird) { if (!bcp.ValidFirst) { //second bezier DrawBezeier(previous.Second, previous.Third, bcp.Second, bcp.Second, context); } else { //third bezier DrawBezeier(previous.Second, previous.Third, bcp.First, bcp.Second, context); } } else { if (!bcp.ValidFirst) { //first bezier context.DrawLine(Color.Black, previous.Second, bcp.Second); } else { //second bezier DrawBezeier(previous.Second, previous.Second, bcp.First, bcp.Second, context); } } } previous = bcp; } }
private void DrawAnchor(BezierControlPoint bcp, IBezierDrawContext context) { if (SelectedPoint == bcp) { FillSquare(bcp.Second, context); if (bcp.ValidFirst) { FillSquare(bcp.First, context); context.DrawLine(Color.Black, bcp.First, bcp.Second); } if (bcp.ValidThird) { FillSquare(bcp.Third, context); context.DrawLine(Color.Black, bcp.Second, bcp.Third); } } else { DrawSquare(bcp.Second, context); } }
private void DrawBezeier(PointF p1, PointF p2, PointF p3, PointF p4, IBezierDrawContext context) { PointF lastbezeirpoint, bezeirpoint; lastbezeirpoint = p1; var count = BezierCaliculate.AboutBezeirCount(ref p1, ref p2, ref p3, ref p4); for (int i = count; i >= 0; i--) { float t = (float)i / count; bezeirpoint = BezierCaliculate.GetBezeirPoint(ref p1, ref p2, ref p3, ref p4, ref t); context.DrawLine(Color.Black, lastbezeirpoint, bezeirpoint); lastbezeirpoint = bezeirpoint; } }
private void DrawNormalData(IBezierDrawContext context) { BezierControlPoint previous = null; for (int i = 0; i < data.Count; i++) { var bcp = data[i] as BezierControlPoint; if ((dmode & DrawMode.Anchor) == DrawMode.Anchor) { DrawAnchor(bcp, context); } if ((dmode & DrawMode.Line) == DrawMode.Line) { if (previous != null) { if (previous.ValidThird) { if (!bcp.ValidFirst) { //second bezier DrawBezeier(previous.Second, previous.Third, bcp.Second, bcp.Second, context); } else { //third bezier DrawBezeier(previous.Second, previous.Third, bcp.First, bcp.Second, context); } } else { if (!bcp.ValidFirst) { //first bezier context.DrawLine(Color.Black, previous.Second, bcp.Second); } else { //second bezier DrawBezeier(previous.Second, previous.Second, bcp.First, bcp.Second, context); } } } } previous = bcp; } }
private void DrawCenter(IBezierDrawContext context) { context.DrawLine(Color.FromArgb(128, 0, 0, 0), new Point(bezierControl1.Width / 2, 0), new Point(bezierControl1.Width / 2, bezierControl1.Height)); context.DrawLine(Color.FromArgb(128, 0, 0, 0), new Point(0, bezierControl1.Height / 2), new Point(bezierControl1.Width, bezierControl1.Height / 2)); }