コード例 #1
0
        public PointOnPath AdvancePoint(PointOnPath pt, ref double dist)
        {
            // assert that we're looking at the same segment
            Debug.Assert(Equals(pt.segment));

            if (pt.dist + dist <= 0)
            {
                // handle the case of negative distance going before start point
                dist += pt.dist;
                return(StartPoint);
            }
            else if (pt.dist + dist >= cb.ArcLength)
            {
                // handle the case of positive distance going after end point
                dist -= cb.ArcLength - pt.dist;
                return(EndPoint);
            }
            else
            {
                // we're in the range that we can achieve
                double targetDist = pt.dist + dist;
                double tValue     = cb.FindT(targetDist);
                double actDist    = cb.PartialArcLength(tValue);

                dist = 0;
                return(new PointOnPath(this, targetDist, cb.Bt(tValue)));
            }
        }
コード例 #2
0
        public static void DrawBezier(GLPen pen, PointF startP, PointF ctrl1, PointF ctrl2, PointF endP)
        {
            CubicBezier cb = new CubicBezier(Utility.ToCoord(startP), Utility.ToCoord(ctrl1), Utility.ToCoord(ctrl2), Utility.ToCoord(endP));

            pen.GLApplyPen();
            Gl.glBegin(Gl.GL_LINE_STRIP);
            //iterate this bitch
            for (double i = 0; i < 1.0; i += .025)
            {
                PointF p = Utility.ToPointF(cb.Bt(i));
                Gl.glVertex2f(p.X, p.Y);
            }

            PointF p1 = Utility.ToPointF(cb.Bt(1));

            Gl.glVertex2f(p1.X, p1.Y);

            Gl.glEnd();
        }
コード例 #3
0
        public void DrawBezier(IPen pen, PointF pt1, PointF pt2, PointF pt3, PointF pt4)
        {
            CubicBezier cb = new CubicBezier(Utility.ToCoord(pt1), Utility.ToCoord(pt2), Utility.ToCoord(pt3), Utility.ToCoord(pt4));

            ApplyPen(pen);
            Gl.glBegin(Gl.GL_LINE_STRIP);
            //iterate this bitch
            for (double i = 0; i < 1.0; i += .025)
            {
                PointF p = Utility.ToPointF(cb.Bt(i));
                Gl.glVertex2f(p.X, p.Y);
            }

            PointF p1 = Utility.ToPointF(cb.Bt(1));

            Gl.glVertex2f(p1.X, p1.Y);

            Gl.glEnd();
        }