/// <summary>
        /// create lines from curve
        /// </summary>
        /// <param name="vxs"></param>
        public static void MakeLines(this Curve3 curve, VertexStore vxs, double x1, double y1,
                                     double cx, double cy,
                                     double x2, double y2)
        {
            CreateBezierVxs3(vxs,
                             new PixelFarm.VectorMath.Vector2(x1, y1),
                             new PixelFarm.VectorMath.Vector2(x2, y2),
                             new PixelFarm.VectorMath.Vector2(cx, cy));
            return;
            //if (this.m_approximation_method == Curves.CurveApproximationMethod.Inc)
            //{
            //    //m_curve_inc.Init(x1, y1, cx, cy, x2, y2);
            //    //bool isFirst = true;
            //    //foreach (VertexData currentVertextData in m_curve_inc.GetVertexIter())
            //    //{
            //    //    if (isFirst)
            //    //    {
            //    //        isFirst = false;
            //    //        continue;
            //    //    }

            //    //    if (ShapePath.IsEmpty(currentVertextData.command))
            //    //    {
            //    //        break;
            //    //    }

            //    //    VertexData vertexData = new VertexData(
            //    //       NxCmdAndFlags.LineTo,
            //    //       currentVertextData.position);

            //    //    vxs.AddVertex(vertexData);
            //    //}
            //}
            //else
            //{
            //    m_curve_div.Init(x1, y1, cx, cy, x2, y2);
            //    m_curve_div.MakeLines(vxs);
            //}

            ////---------------------------------------------------------------------
            //IEnumerator<VertexData> curveIterator = this.GetVertexIter().GetEnumerator();
            //curveIterator.MoveNext(); // First call returns path_cmd_move_to
            //do
            //{
            //    curveIterator.MoveNext();
            //    VertexData currentVertextData = curveIterator.Current;
            //    if (ShapePath.IsEmpty(currentVertextData.command))
            //    {
            //        break;
            //    }

            //    VertexData vertexData = new VertexData(
            //       NxCmdAndFlags.LineTo,
            //       currentVertextData.position);

            //    vxs.AddVertex(vertexData);

            //} while (!ShapePath.IsEmpty(curveIterator.Current.command));
        }
 public CurveConverter(IVertexSource source)
 {
     m_curve3 = new Curve3();
     m_curve4 = new Curve4();
     m_source = (source);
     m_last_x = (0.0);
     m_last_y = (0.0);
 }
Exemple #3
0
        internal static NativeCurve3 *CopyCurve3ToNativeCurve3(Curve3 managedCurve)
        {
            NativeCurve *x = CopyCurveToNativeCurve(managedCurve.X);
            NativeCurve *y = CopyCurveToNativeCurve(managedCurve.Y);
            NativeCurve *z = CopyCurveToNativeCurve(managedCurve.Z);

            return(util_Curve3_Ctor(x, y, z));
        }
 public CurveConverter(IVertexSource source)
 {
     m_curve3 = new Curve3();
     m_curve4 = new Curve4();
     m_source=(source);
     m_last_x=(0.0);
     m_last_y=(0.0);
 }
Exemple #5
0
 /// <summary>
 /// create lines from curve
 /// </summary>
 /// <param name="vxs"></param>
 public static void MakeLines(this Curve3 curve, VertexStore vxs, double x1, double y1,
                              double cx, double cy,
                              double x2, double y2)
 {
     CreateBezierVxs3(vxs,
                      x1, y1,
                      cx, cy,
                      x2, y2);
 }
Exemple #6
0
        static Msdfgen.Shape CreateMsdfShape(List <Contour> contours)
        {
            var shape = new Msdfgen.Shape();
            int j     = contours.Count;

            for (int i = 0; i < j; ++i)
            {
                var cnt = new Msdfgen.Contour();
                shape.contours.Add(cnt);

                Contour            contour = contours[i];
                List <ContourPart> parts   = contour.parts;
                int m = parts.Count;
                for (int n = 0; n < m; ++n)
                {
                    ContourPart p = parts[n];
                    switch (p.Kind)
                    {
                    default: throw new NotSupportedException();

                    case PartKind.Curve3:
                    {
                        Curve3 curve3 = (Curve3)p;
                        cnt.AddQuadraticSegment(
                            curve3.FirstPoint.X, curve3.FirstPoint.Y,
                            curve3.x1, curve3.y1,
                            curve3.x2, curve3.y2
                            );
                    }
                    break;

                    case PartKind.Curve4:
                    {
                        Curve4 curve4 = (Curve4)p;
                        cnt.AddCubicSegment(
                            curve4.FirstPoint.X, curve4.FirstPoint.Y,
                            curve4.x1, curve4.y1,
                            curve4.x2, curve4.y2,
                            curve4.x3, curve4.y3);
                    }
                    break;

                    case PartKind.Line:
                    {
                        Line line = (Line)p;
                        cnt.AddLine(
                            line.FirstPoint.X, line.FirstPoint.Y,
                            line.x1, line.y1);
                    }
                    break;
                    }
                }
            }
            return(shape);
        }
Exemple #7
0
        static Contour CreateFitContour(Contour contour, float pixelScale, bool x_axis, bool y_axis)
        {
            Contour            newc  = new Contour();
            List <ContourPart> parts = contour.parts;
            int m = parts.Count;

            for (int n = 0; n < m; ++n)
            {
                ContourPart p = parts[n];
                switch (p.Kind)
                {
                default: throw new NotSupportedException();

                case PartKind.Curve3:
                {
                    Curve3 curve3 = (Curve3)p;
                    newc.AddPart(new Curve3(
                                     curve3.FirstPoint.X * pixelScale, curve3.FirstPoint.Y * pixelScale,
                                     curve3.x1 * pixelScale, curve3.y1 * pixelScale,
                                     curve3.x2 * pixelScale, curve3.y2 * pixelScale));
                }
                break;

                case PartKind.Curve4:
                {
                    Curve4 curve4 = (Curve4)p;
                    newc.AddPart(new Curve4(
                                     curve4.FirstPoint.X * pixelScale, curve4.FirstPoint.Y * pixelScale,
                                     curve4.x1 * pixelScale, curve4.y1 * pixelScale,
                                     curve4.x2 * pixelScale, curve4.y2 * pixelScale,
                                     curve4.x3 * pixelScale, curve4.y3 * pixelScale
                                     ));
                }
                break;

                case PartKind.Line:
                {
                    Line line = (Line)p;
                    newc.AddPart(new Line(
                                     line.FirstPoint.X * pixelScale, line.FirstPoint.Y * pixelScale,
                                     line.x1 * pixelScale, line.y1 * pixelScale
                                     ));
                }
                break;
                }
            }
            return(newc);
        }
Exemple #8
0
        public curve3_ctrl_impl()
            : base(new Vector2())
        {
            m_stroke  = new Stroke(m_curve);
            m_poly    = new polygon_ctrl_impl(3, 5.0);
            m_idx     = 0;
            m_curve   = new Curve3();
            m_ellipse = new MatterHackers.Agg.VertexSource.Ellipse();

            m_poly.in_polygon_check(false);
            m_poly.SetXN(0, 100.0);
            m_poly.SetYN(0, 0.0);
            m_poly.SetXN(1, 100.0);
            m_poly.SetYN(1, 50.0);
            m_poly.SetXN(2, 50.0);
            m_poly.SetYN(2, 100.0);
        }
Exemple #9
0
        protected override void Initialize()
        {
            base.Initialize();

            Material = Material.Library.Get("Particles/poof.mat");

            SpawnRadius         = 100;
            SpawnRadialVelocity = Curve.Random(-500, 500);
            Drag               = 5;
            SpawnSize          = Curve3.Random(250, 400);
            LifeScale          = Curve3.Linear(0.75, 1.0);
            SpawnColor         = new Color(0x4c4c4c);
            AlphaScaleOverLife = new Curve(0.75, 0);
            LifeTime           = Curve.Random(1.5, 2);
            Align              = ParticleAlignment.Square;
            Sort               = ParticleSort.ProjectedDistance;

            CollisionMax     = 0;
            EnableCollisions = true;

            WithBurst(500);

            new ParticleSystem
            {
                Position           = Position,
                Rotation           = Rotation,
                Material           = Material.Library.Get("Particles/spark.mat"),
                SpawnColor         = Curve3.RandomLinear(new Color(1, 0.7, 0.4), new Color(1, 1, 0.4)),
                LifeTime           = Curve.Random(1, 1.5),
                SpawnSize          = Curve3.RandomLinear(new Vector3(2, 3, 1), new Vector3(5, 15, 1)),
                LifeScale          = Curve3.Linear(1.0, 0.0),
                Drag               = 5,
                AlphaScaleOverLife = Curve.Linear(1, 0),
                CollisionMax       = 3,
                EnableCollisions   = true,
                CollisionDamp      = Curve3.Random(0.1, 0.5),
                Align              = ParticleAlignment.Velocity,
                OnCollisionMax     = ParticleCollisionComplete.Freeze,
                SpeedScale         = new Vector3(1, 0.01, 1),
                SpeedScaleMax      = new Vector3(1, 100, 1),
                Sort               = ParticleSort.Distance,
            }
            .WithConeVelocity(Curve.Random(0, 360), Curve.Random(1000, 2000))
            .WithBurst(250)
            .Spawn();
        }
Exemple #10
0
        public curve3_ctrl_impl()
            :
            base(M.Zero <T>(), M.Zero <T>(), M.One <T>(), M.One <T>())
        {
            m_stroke  = new ConvStroke <T>(m_curve);
            m_poly    = new polygon_ctrl_impl <T>(3, M.New <T>(5.0));
            m_idx     = 0;
            m_curve   = new Curve3 <T>();
            m_ellipse = new Ellipse <T>();

            m_poly.in_polygon_check(false);
            m_poly.SetXN(0, M.New <T>(100.0));
            m_poly.SetYN(0, M.Zero <T>());
            m_poly.SetXN(1, M.New <T>(100.0));
            m_poly.SetYN(1, M.New <T>(50.0));
            m_poly.SetXN(2, M.New <T>(50.0));
            m_poly.SetYN(2, M.New <T>(100.0));
        }