Exemple #1
0
        public void GetSmooth()
        {
            if (this.isValidSmooth)
            {
                return;
            }
            this.isValidSmooth = true;
            //lets smooth it
            //string str1 = dbugDumpPointsToString(contPoints);
            //string str2 = dbugDumpPointsToString2(contPoints);
            //var data2 = CurvePreprocess.RdpReduce(contPoints, 2);
            var data2 = contPoints;

            CubicBezier[] cubicBzs = CurveFit.Fit(data2, 8);

            //PathWriter pWriter = new PathWriter();
            //pWriter.StartFigure();

            //int j = cubicBzs.Length;
            //for (int i = 0; i < j; ++i)
            //{
            //    CubicBezier bz = cubicBzs[i];
            //    pWriter.MoveTo(bz.p0.x, bz.p0.y);
            //    pWriter.LineTo(bz.p0.x, bz.p0.y);

            //    pWriter.Curve4(bz.p1.x, bz.p1.y,
            //            bz.p2.x, bz.p2.y,
            //            bz.p3.x, bz.p3.y);
            //}
            //pWriter.CloseFigureCCW();
            vxs = new VertexStore();
            int j = cubicBzs.Length;

            //1.
            if (j > 0)
            {
                //1st
                CubicBezier bz0 = cubicBzs[0];
                vxs.AddMoveTo(bz0.p0.x, bz0.p0.y);
                vxs.AddLineTo(bz0.p0.x, bz0.p0.y);
                vxs.AddP3c(bz0.p1.x, bz0.p1.y);
                vxs.AddP3c(bz0.p2.x, bz0.p2.y);
                vxs.AddLineTo(bz0.p3.x, bz0.p3.y);
                //-------------------------------
                for (int i = 1; i < j; ++i) //start at 1
                {
                    CubicBezier bz = cubicBzs[i];
                    vxs.AddP3c(bz.p1.x, bz.p1.y);
                    vxs.AddP3c(bz.p2.x, bz.p2.y);
                    vxs.AddLineTo(bz.p3.x, bz.p3.y);
                }
                //-------------------------------
                //close
                vxs.AddLineTo(bz0.p0.x, bz0.p0.y);
            }
            vxs.AddCloseFigure();
            PixelFarm.Agg.VertexSource.CurveFlattener cflat = new PixelFarm.Agg.VertexSource.CurveFlattener();
            vxs = cflat.MakeVxs(vxs);
        }
 //-----------------------------------------------------------------------
 public void Curve4(double p2x, double p2y,
                    double p3x, double p3y,
                    double x, double y)
 {
     this.latestSVGPathCmd = SvgPathCommand.CurveTo;
     myvxs.AddP3c(p2x, p2y);
     myvxs.AddP3c(p3x, p3y);
     myvxs.AddLineTo(this.lastX = x, this.lastY = y);
 }
Exemple #3
0
 //-----------------------------------------------------------------------
 public void Curve4(double x1, double y1,
                    double x2, double y2,
                    double x3, double y3)
 {
     this.latestSVGPathCmd = SvgPathCommand.CurveTo;
     myvxs.AddP3c(x1, y1);
     myvxs.AddP3c(x2, y2);
     myvxs.AddLineTo(this.latest_x = x3, this.latest_y = y3);
 }
Exemple #4
0
 //-----------------------------------------------------------------------
 public void Curve4(double x1, double y1,
                    double x2, double y2,
                    double x3, double y3)
 {
     _latestSVGPathCmd = SvgPathCommand.CurveTo;
     _myvxs.AddP3c(x1, y1);
     _myvxs.AddP3c(x2, y2);
     _c2 = new Vector2(x2, y2);
     _myvxs.AddLineTo(_latest_x = x3, _latest_y = y3);
 }