/// <summary>
        /// we do NOT store vxs/vxsSnap
        /// </summary>
        /// <param name="vxsSnap"></param>
        /// <param name="color"></param>
        public void Render(VertexStoreSnap vxsSnap, Drawing.Color color)
        {
            //reset rasterizer before render each vertextSnap
            //-----------------------------
            sclineRas.Reset();
            Affine transform = this.CurrentTransformMatrix;

            if (!transform.IsIdentity())
            {
                VectorToolBox.GetFreeVxs(out var v1);
                transform.TransformToVxs(vxsSnap, v1);
                sclineRas.AddPath(v1);
                VectorToolBox.ReleaseVxs(ref v1);
                //-------------------------
                //since sclineRas do NOT store vxs
                //then we can reuse the vxs***
                //-------------------------
            }
            else
            {
                sclineRas.AddPath(vxsSnap);
            }
            _bmpRasterizer.RenderWithColor(destImageReaderWriter, sclineRas, sclinePack8, color);
            unchecked { destImageChanged++; };
            //-----------------------------
        }
Пример #2
0
 public override void Draw(VertexStoreSnap snap)
 {
     _glsx.DrawGfxPath(
         this._strokeColor,
         _igfxPathBuilder.CreateGraphicsPath(snap)
         );
 }
Пример #3
0
        public static bool GetBoundingRect(VertexStoreSnap vs, ref RectD rect)
        {
            double x1, y1, x2, y2;
            bool   rValue = GetBoundingRectSingle(vs, out x1, out y1, out x2, out y2);

            if (x1 < rect.Left)
            {
                rect.Left = x1;
            }
            if (y1 < rect.Bottom)
            {
                rect.Bottom = y1;
            }
            if (x2 > rect.Right)
            {
                rect.Right = x2;
            }

            if (y2 > rect.Top)
            {
                rect.Top = y2;
            }

            return(rValue);
        }
Пример #4
0
        conv_poly_counter(VertexStoreSnap src)
        {
            m_contours = 0;
            m_points   = 0;
            var       snapIter = src.GetVertexSnapIter();
            VertexCmd cmd;
            double    x, y;

            do
            {
                cmd = snapIter.GetNextVertex(out x, out y);
                if (VertexHelper.IsVertextCommand(cmd))
                {
                    ++m_points;
                }

                if (VertexHelper.IsMoveTo(cmd))
                {
                    ++m_contours;
                }
            } while (cmd != VertexCmd.Stop);
            //foreach (VertexData vertexData in src.GetVertexIter())
            //{
            //    if (ShapePath.IsVertextCommand(vertexData.command))
            //    {
            //        ++m_points;
            //    }

            //    if (ShapePath.IsMoveTo(vertexData.command))
            //    {
            //        ++m_contours;
            //    }
            //}
        }
Пример #5
0
 public override RenderVx CreateRenderVx(VertexStoreSnap snap)
 {
     throw new NotSupportedException();
     //var renderVx = new WinGdiRenderVx(snap);
     //renderVx.path = VxsHelper.CreateGraphicsPath(snap);
     //return renderVx;
 }
Пример #6
0
        public BlurWithPainter()
        {
            //m_rbuf2 = new ReferenceImage();
            m_shape_bounds           = new RectD();
            m_shadow_ctrl            = new PolygonEditWidget(4);
            this.FlattenCurveChecked = true;
            this.BlurMethod          = BlurMethod.RecursiveBlur;
            this.BlurRadius          = 15;
            Font svgFont = SvgFontStore.LoadFont("svg-LiberationSansFont", 300);

            m_pathVxs = svgFont.GetGlyph('a').originalVxs;// typeFaceForLargeA.GetGlyphForCharacter('a');
            Affine shape_mtx = Affine.NewMatix(AffinePlan.Translate(150, 100));

            m_pathVxs = shape_mtx.TransformToVxs(m_pathVxs);
            var curveFlattener = new CurveFlattener();

            m_path_2 = new VertexStoreSnap(curveFlattener.MakeVxs(m_pathVxs));
            BoundingRect.GetBoundingRect(m_path_2, ref m_shape_bounds);
            m_shadow_ctrl.SetXN(0, m_shape_bounds.Left);
            m_shadow_ctrl.SetYN(0, m_shape_bounds.Bottom);
            m_shadow_ctrl.SetXN(1, m_shape_bounds.Right);
            m_shadow_ctrl.SetYN(1, m_shape_bounds.Bottom);
            m_shadow_ctrl.SetXN(2, m_shape_bounds.Right);
            m_shadow_ctrl.SetYN(2, m_shape_bounds.Top);
            m_shadow_ctrl.SetXN(3, m_shape_bounds.Left);
            m_shadow_ctrl.SetYN(3, m_shape_bounds.Top);
            m_shadow_ctrl.LineColor = ColorRGBAf.MakeColorRGBA(0f, 0.3f, 0.5f, 0.3f);
        }
Пример #7
0
 public override void Draw(VertexStoreSnap snap)
 {
     _canvas.DrawGfxPath(
         this._strokeColor,
         InternalGraphicsPath.CreateGraphicsPath(snap)
         );
 }
Пример #8
0
 public static void DrawVxsSnap(SKCanvas g, VertexStoreSnap vxsSnap, SKPaint stroke)
 {
     using (var p = CreateGraphicsPath(vxsSnap))
     {
         g.DrawPath(p, stroke);
     }
 }
Пример #9
0
 public static void FillVxsSnap(SKCanvas g, VertexStoreSnap vxsSnap, SKPaint fill)
 {
     using (var p = CreateGraphicsPath(vxsSnap))
     {
         g.DrawPath(p, fill);
     }
 }
Пример #10
0
        public static RectInt GetBoundingRect(VertexStoreSnap vs)
        {
            int  x1, y1, x2, y2;
            bool rValue = GetBoundingRect(vs, out x1, out y1, out x2, out y2);

            return(new RectInt(x1, y1, x2, y2));
        }
Пример #11
0
        void CreateAndRenderCombined(Graphics2D graphics2D, VertexStoreSnap ps1, VertexStoreSnap ps2)
        {
            PathWriter combined = null;

            switch (this.OpOption)
            {
            case OperationOption.OR:
                combined = CombinePaths(ps1, ps2, ClipType.ctUnion);
                break;

            case OperationOption.AND:
                combined = CombinePaths(ps1, ps2, ClipType.ctIntersection);
                break;

            case OperationOption.XOR:
                combined = CombinePaths(ps1, ps2, ClipType.ctXor);
                break;

            case OperationOption.A_B:
                combined = CombinePaths(ps1, ps2, ClipType.ctDifference);
                break;

            case OperationOption.B_A:
                combined = CombinePaths(ps2, ps1, ClipType.ctDifference);
                break;
            }

            if (combined != null)
            {
                graphics2D.Render(combined.MakeVertexSnap(), ColorRGBAf.MakeColorRGBA(0.5f, 0.0f, 0f, 0.5f));
            }
        }
Пример #12
0
        public override RenderVx CreateRenderVx(VertexStoreSnap snap)
        {
            var renderVx = new WinGdiRenderVx(snap);

            renderVx.path = VxsHelper.CreateGraphicsPath(snap);
            return(renderVx);
        }
Пример #13
0
 public static void FillVxsSnap(Graphics g, VertexStoreSnap vxsSnap, Color c)
 {
     using (System.Drawing.Drawing2D.GraphicsPath p = CreateGraphicsPath(vxsSnap))
     {
         _br.Color = ToDrawingColor(c);
         g.FillPath(_br, p);
     }
 }
Пример #14
0
 public static void DrawVxsSnap(Graphics g, VertexStoreSnap vxsSnap, Color c)
 {
     using (System.Drawing.Drawing2D.GraphicsPath p = CreateGraphicsPath(vxsSnap))
     {
         _pen.Color = ToDrawingColor(c);
         g.DrawPath(_pen, p);
     }
 }
Пример #15
0
        public static void Draw(this Painter p, VertexStoreSnap vxs, Color color)
        {
            Color prevColor = p.StrokeColor;

            p.StrokeColor = color;
            p.Draw(vxs);
            p.StrokeColor = prevColor;
        }
Пример #16
0
        public static void Fill(this Painter p, VertexStoreSnap snap, Color color)
        {
            Color prevColor = p.FillColor;

            p.FillColor = color;
            p.Fill(snap);
            p.FillColor = prevColor;
        }
Пример #17
0
        static PathWriter CombinePaths(VertexStoreSnap a, VertexStoreSnap b, ClipType clipType)
        {
            List <List <IntPoint> > aPolys = CreatePolygons(a);
            List <List <IntPoint> > bPolys = CreatePolygons(b);

            Clipper clipper = new Clipper();

            clipper.AddPaths(aPolys, PolyType.ptSubject, true);
            clipper.AddPaths(bPolys, PolyType.ptClip, true);

            List <List <IntPoint> > intersectedPolys = new List <List <IntPoint> >();

            clipper.Execute(clipType, intersectedPolys);

            PathWriter output = new PathWriter();

            foreach (List <IntPoint> polygon in intersectedPolys)
            {
                bool first = true;
                int  j     = polygon.Count;

                if (j > 0)
                {
                    //first one
                    IntPoint point = polygon[0];

                    output.MoveTo(point.X / 1000.0, point.Y / 1000.0);

                    //next ...
                    if (j > 1)
                    {
                        for (int i = 1; i < j; ++i)
                        {
                            point = polygon[i];
                            output.LineTo(point.X / 1000.0, point.Y / 1000.0);
                        }
                    }
                }
                //foreach (IntPoint point in polygon)
                //{
                //    if (first)
                //    {
                //        output.AddVertex(point.X / 1000.0, point.Y / 1000.0, ShapePath.FlagsAndCommand.CommandMoveTo);
                //        first = false;
                //    }
                //    else
                //    {
                //        output.AddVertex(point.X / 1000.0, point.Y / 1000.0, ShapePath.FlagsAndCommand.CommandLineTo);
                //    }
                //}

                output.CloseFigure();
            }


            output.Stop();
            return(output);
        }
Пример #18
0
        //-----------------------------------------------------------------------------------------------------------------
        public override RenderVx CreateRenderVx(VertexStoreSnap snap)
        {
            //store internal gfx path inside render vx

            //1.
            InternalGraphicsPath p = _igfxPathBuilder.CreateGraphicsPathForRenderVx(snap);

            return(new GLRenderVx(p));
        }
Пример #19
0
        //-----------------------------------------------------bounding_rect_single
        //template<class VertexSource, class CoordT>
        static bool GetBoundingRect(
            VertexStoreSnap vs,
            out int x1, out int y1,
            out int x2, out int y2)
        {
            double x_d   = 0;
            double y_d   = 0;
            int    x     = 0;
            int    y     = 0;
            bool   first = true;

            x1 = 1;
            y1 = 1;
            x2 = 0;
            y2 = 0;

            VertexSnapIter vsnapIter = vs.GetVertexSnapIter();
            VertexCmd      PathAndFlags;

            while (!VertexHelper.IsEmpty(PathAndFlags = vsnapIter.GetNextVertex(out x_d, out y_d)))
            {
                x = (int)x_d;
                y = (int)y_d;
                if (VertexHelper.IsVertextCommand(PathAndFlags))
                {
                    if (first)
                    {
                        x1    = x;
                        y1    = y;
                        x2    = x;
                        y2    = y;
                        first = false;
                    }
                    else
                    {
                        if (x < x1)
                        {
                            x1 = x;
                        }
                        if (y < y1)
                        {
                            y1 = y;
                        }
                        if (x > x2)
                        {
                            x2 = x;
                        }
                        if (y > y2)
                        {
                            y2 = y;
                        }
                    }
                }
            }
            return(x1 <= x2 && y1 <= y2);
        }
Пример #20
0
 public static bool GetBoundingRect(VertexStoreSnap vs, ref RectD rect)
 {
     double x1, y1, x2, y2;
     bool rValue = GetBoundingRectSingle(vs, out x1, out y1, out x2, out y2);
     rect.Left = x1;
     rect.Bottom = y1;
     rect.Right = x2;
     rect.Top = y2;
     return rValue;
 }
Пример #21
0
        public static bool GetBoundingRect(VertexStoreSnap vs, ref RectInt rect)
        {
            int  x1, y1, x2, y2;
            bool rValue = GetBoundingRect(vs, out x1, out y1, out x2, out y2);

            rect.Left   = x1;
            rect.Bottom = y1;
            rect.Right  = x2;
            rect.Top    = y2;
            return(rValue);
        }
Пример #22
0
        //// Concatenate path. The path is added as is.
        public void ConcatPath(VertexStoreSnap s)
        {
            double         x, y;
            VertexCmd      cmd_flags;
            VertexSnapIter snapIter = s.GetVertexSnapIter();

            while ((cmd_flags = snapIter.GetNextVertex(out x, out y)) != VertexCmd.NoMore)
            {
                myvxs.AddVertex(x, y, cmd_flags);
            }
        }
Пример #23
0
        public static System.Drawing.Drawing2D.GraphicsPath CreateGraphicsPath(VertexStoreSnap vxsSnap)
        {
            VertexSnapIter vxsIter     = vxsSnap.GetVertexSnapIter();
            double         prevX       = 0;
            double         prevY       = 0;
            double         prevMoveToX = 0;
            double         prevMoveToY = 0;
            var            brush_path  = new System.Drawing.Drawing2D.GraphicsPath(FillMode.Winding);//*** winding for overlapped path

            for (;;)
            {
                double    x, y;
                VertexCmd cmd = vxsIter.GetNextVertex(out x, out y);
                switch (cmd)
                {
                case PixelFarm.Agg.VertexCmd.MoveTo:
                    prevMoveToX = prevX = x;
                    prevMoveToY = prevY = y;
                    brush_path.StartFigure();
                    break;

                case PixelFarm.Agg.VertexCmd.LineTo:

                    brush_path.AddLine((float)prevX, (float)prevY, (float)x, (float)y);
                    prevX = x;
                    prevY = y;
                    break;

                case PixelFarm.Agg.VertexCmd.CloseAndEndFigure:
                    //from current point
                    //
                    brush_path.AddLine((float)prevX, (float)prevY, (float)prevMoveToX, (float)prevMoveToY);
                    prevX = prevMoveToX;
                    prevY = prevMoveToY;
                    brush_path.CloseFigure();
                    break;

                case PixelFarm.Agg.VertexCmd.EndFigure:
                    goto EXIT_LOOP;
                    break;

                case PixelFarm.Agg.VertexCmd.HasMore:
                    break;

                case PixelFarm.Agg.VertexCmd.Stop:
                    goto EXIT_LOOP;

                default:
                    throw new NotSupportedException();
                }
            }
EXIT_LOOP:
            return(brush_path);
        }
Пример #24
0
        /// <summary>
        /// we do NOT store vxs, return original outputVxs
        /// </summary>
        /// <param name="src"></param>
        /// <param name="outputVxs"></param>
        /// <returns></returns>
        public static VertexStore TransformToVxs(this Affine aff, VertexStoreSnap src, VertexStore outputVxs)
        {
            var       snapIter = src.GetVertexSnapIter();
            VertexCmd cmd;
            double    x, y;

            while ((cmd = snapIter.GetNextVertex(out x, out y)) != VertexCmd.NoMore)
            {
                aff.Transform(ref x, ref y);
                outputVxs.AddVertex(x, y, cmd);
            }
            return(outputVxs);
        }
Пример #25
0
        /// <summary>
        /// fill vertex store, we do NOT store snap
        /// </summary>
        /// <param name="vxs"></param>
        /// <param name="c"></param>
        public override void Fill(VertexStoreSnap snap)
        {
            //BitmapExt
            if (this._renderQuality == RenderQualtity.Fast)
            {
                FillWithBxt(snap);
                return;
            }

            //Agg
            sclineRas.AddPath(snap);
            _bmpRasterizer.RenderWithColor(this._aggsx.DestImage, sclineRas, scline, fillColor);
        }
Пример #26
0
        public static VertexStore TransformToVxs(this Perspective perspecitveTx, VertexStoreSnap snap, VertexStore vxs)
        {
            var       vsnapIter = snap.GetVertexSnapIter();
            double    x, y;
            VertexCmd cmd;

            do
            {
                cmd = vsnapIter.GetNextVertex(out x, out y);
                perspecitveTx.Transform(ref x, ref y);
                vxs.AddVertex(x, y, cmd);
            } while (!VertexHelper.IsEmpty(cmd));
            return(vxs);
        }
Пример #27
0
        public VertexStore TransformToVxs(VertexStoreSnap src)
        {
            var       vxs      = new VertexStore();
            var       snapIter = src.GetVertexSnapIter();
            VertexCmd cmd;
            double    x, y;

            while ((cmd = snapIter.GetNextVertex(out x, out y)) != VertexCmd.Stop)
            {
                this.Transform(ref x, ref y);
                vxs.AddVertex(x, y, cmd);
            }
            return(vxs);
        }
Пример #28
0
        //--------------------------------------------------------------------
        // Join path. The path is joined with the existing one, that is,
        // it behaves as if the pen of a plotter was always down (drawing)
        //template<class VertexSource>
        public void JoinPath(VertexStoreSnap s)
        {
            double    x, y;
            var       snapIter = s.GetVertexSnapIter();
            VertexCmd cmd      = snapIter.GetNextVertex(out x, out y);

            if (cmd == VertexCmd.Stop)
            {
                return;
            }

            if (VertexHelper.IsVertextCommand(cmd))
            {
                double    x0, y0;
                VertexCmd flags0 = GetLastVertex(out x0, out y0);

                if (VertexHelper.IsVertextCommand(flags0))
                {
                    if (AggMath.calc_distance(x, y, x0, y0) > AggMath.VERTEX_DISTANCE_EPSILON)
                    {
                        if (VertexHelper.IsMoveTo(cmd))
                        {
                            cmd = VertexCmd.LineTo;
                        }
                        myvxs.AddVertex(x, y, cmd);
                    }
                }
                else
                {
                    if (VertexHelper.IsEmpty(flags0))
                    {
                        cmd = VertexCmd.MoveTo;
                    }
                    else
                    {
                        if (VertexHelper.IsMoveTo(cmd))
                        {
                            cmd = VertexCmd.LineTo;
                        }
                    }
                    myvxs.AddVertex(x, y, cmd);
                }
            }

            while ((cmd = snapIter.GetNextVertex(out x, out y)) != VertexCmd.Stop)
            {
                myvxs.AddVertex(x, y, VertexHelper.IsMoveTo(cmd) ? VertexCmd.LineTo : cmd);
            }
        }
Пример #29
0
        public static VertexStore TranslateTransformToVxs(VertexStoreSnap src, double dx, double dy)
        {
            var       vxs      = new VertexStore();
            var       snapIter = src.GetVertexSnapIter();
            VertexCmd cmd;
            double    x, y;

            while ((cmd = snapIter.GetNextVertex(out x, out y)) != VertexCmd.Stop)
            {
                x += dx;
                y += dy;
                vxs.AddVertex(x, y, cmd);
            }
            return(vxs);
        }
Пример #30
0
        public VertexStore TransformToVxs(VertexStoreSnap snap)
        {
            var       vxs = new VertexStore();
            var       vsnapIter = snap.GetVertexSnapIter();
            double    x, y;
            VertexCmd cmd;

            do
            {
                cmd = vsnapIter.GetNextVertex(out x, out y);
                this.Transform(ref x, ref y);
                vxs.AddVertex(x, y, cmd);
            } while (!VertexHelper.IsEmpty(cmd));
            return(vxs);
        }
Пример #31
0
        void AddPath(VertexStoreSnap s)
        {
            double    x;
            double    y;
            VertexCmd cmd;
            var       snapIter = s.GetVertexSnapIter();

            while ((cmd = snapIter.GetNextVertex(out x, out y)) != VertexCmd.NoMore)
            {
                AddVertex(x, y, cmd);
            }



            Render(false);
        }
Пример #32
0
 static List<List<IntPoint>> CreatePolygons(VertexStoreSnap a)
 {
     List<List<IntPoint>> allPolys = new List<List<IntPoint>>();
     List<IntPoint> currentPoly = null;
     VertexData last = new VertexData();
     VertexData first = new VertexData();
     bool addedFirst = false;
     var snapIter = a.GetVertexSnapIter();
     double x, y;
     VertexCmd cmd = snapIter.GetNextVertex(out x, out y);
     do
     {
         if (cmd == VertexCmd.LineTo)
         {
             if (!addedFirst)
             {
                 currentPoly.Add(new IntPoint((long)(last.x * 1000), (long)(last.y * 1000)));
                 addedFirst = true;
                 first = last;
             }
             currentPoly.Add(new IntPoint((long)(x * 1000), (long)(y * 1000)));
             last = new VertexData(cmd, x, y);
         }
         else
         {
             addedFirst = false;
             currentPoly = new List<IntPoint>();
             allPolys.Add(currentPoly);
             if (cmd == VertexCmd.MoveTo)
             {
                 last = new VertexData(cmd, x, y);
             }
             else
             {
                 last = first;
             }
         }
         cmd = snapIter.GetNextVertex(out x, out y);
     } while (cmd != VertexCmd.Stop);
     return allPolys;
 }
Пример #33
0
        public static List<VertexStore> CombinePaths(VertexStoreSnap a, VertexStoreSnap b, VxsClipperType vxsClipType, bool separateIntoSmallSubPaths)
        {
            ClipType clipType = (ClipType)vxsClipType;
            List<List<IntPoint>> aPolys = CreatePolygons(a);
            List<List<IntPoint>> bPolys = CreatePolygons(b);
            Clipper clipper = new Clipper();
            clipper.AddPaths(aPolys, PolyType.ptSubject, true);
            clipper.AddPaths(bPolys, PolyType.ptClip, true);
            List<List<IntPoint>> intersectedPolys = new List<List<IntPoint>>();
            clipper.Execute(clipType, intersectedPolys);
            List<VertexStore> resultList = new List<VertexStore>();

            PathWriter output = new PathWriter();
            if (separateIntoSmallSubPaths)
            {
                foreach (List<IntPoint> polygon in intersectedPolys)
                {
                    int j = polygon.Count;
                    if (j > 0)
                    {
                        //first one
                        IntPoint point = polygon[0];
                        output.MoveTo(point.X / 1000.0, point.Y / 1000.0);
                        //next others ...
                        if (j > 1)
                        {
                            for (int i = 1; i < j; ++i)
                            {
                                point = polygon[i];
                                output.LineTo(point.X / 1000.0, point.Y / 1000.0);
                            }
                        }

                        output.CloseFigure();
                        resultList.Add(output.Vxs);
                        //---
                        //clear 
                        output.ClearAndStartNewVxs(new VertexStore());
                    }
                }
            }
            else
            {
                foreach (List<IntPoint> polygon in intersectedPolys)
                {
                    int j = polygon.Count;
                    if (j > 0)
                    {
                        //first one
                        IntPoint point = polygon[0];
                        output.MoveTo(point.X / 1000.0, point.Y / 1000.0);
                        //next others ...
                        if (j > 1)
                        {
                            for (int i = 1; i < j; ++i)
                            {
                                point = polygon[i];
                                output.LineTo(point.X / 1000.0, point.Y / 1000.0);
                            }
                        }
                        output.CloseFigure();
                    }

                    //bool first = true;
                    //foreach (IntPoint point in polygon)
                    //{
                    //    if (first)
                    //    {
                    //        output.AddVertex(point.X / 1000.0, point.Y / 1000.0, ShapePath.FlagsAndCommand.CommandMoveTo);
                    //        first = false;
                    //    }
                    //    else
                    //    {
                    //        output.AddVertex(point.X / 1000.0, point.Y / 1000.0, ShapePath.FlagsAndCommand.CommandLineTo);
                    //    }
                    //} 
                }

                output.Stop();
                resultList.Add(output.Vxs);
            }

            return resultList;
        }
Пример #34
0
        //--------------------------------------------------------------------
        // Join path. The path is joined with the existing one, that is, 
        // it behaves as if the pen of a plotter was always down (drawing)
        //template<class VertexSource>  
        public void JoinPath(VertexStoreSnap s)
        {
            double x, y;
            var snapIter = s.GetVertexSnapIter();
            VertexCmd cmd = snapIter.GetNextVertex(out x, out y);
            if (cmd == VertexCmd.Stop)
            {
                return;
            }

            if (VertexHelper.IsVertextCommand(cmd))
            {
                double x0, y0;
                VertexCmd flags0 = GetLastVertex(out x0, out y0);
                if (VertexHelper.IsVertextCommand(flags0))
                {
                    if (AggMath.calc_distance(x, y, x0, y0) > AggMath.VERTEX_DISTANCE_EPSILON)
                    {
                        if (VertexHelper.IsMoveTo(cmd))
                        {
                            cmd = VertexCmd.LineTo;
                        }
                        myvxs.AddVertex(x, y, cmd);
                    }
                }
                else
                {
                    if (VertexHelper.IsEmpty(flags0))
                    {
                        cmd = VertexCmd.MoveTo;
                    }
                    else
                    {
                        if (VertexHelper.IsMoveTo(cmd))
                        {
                            cmd = VertexCmd.LineTo;
                        }
                    }
                    myvxs.AddVertex(x, y, cmd);
                }
            }

            while ((cmd = snapIter.GetNextVertex(out x, out y)) != VertexCmd.Stop)
            {
                myvxs.AddVertex(x, y, VertexHelper.IsMoveTo(cmd) ? VertexCmd.LineTo : cmd);
            }
        }
Пример #35
0
        public void MakeVxs(VertexStoreSnap vsnap, VertexStore vxs)
        {
            m_curve3.Reset();
            m_curve4.Reset();
            var snapIter = vsnap.GetVertexSnapIter();
            CurvePointMode latestCurveMode = CurvePointMode.NotCurve;
            double x, y;
            VertexCmd cmd;
            VectorMath.Vector2 c3p2 = new VectorMath.Vector2();
            VectorMath.Vector2 c4p2 = new VectorMath.Vector2();
            VectorMath.Vector2 c4p3 = new VectorMath.Vector2();
            double lastX = 0;
            double lasty = 0;
            double lastMoveX = 0;
            double lastMoveY = 0;
            do
            {
                //this vertex
                cmd = snapIter.GetNextVertex(out x, out y);
                switch (cmd)
                {
                    case VertexCmd.P2c:
                        {
                            switch (latestCurveMode)
                            {
                                case CurvePointMode.P2:
                                    {
                                    }
                                    break;
                                case CurvePointMode.P3:
                                    {
                                    }
                                    break;
                                case CurvePointMode.NotCurve:
                                    {
                                        c3p2.x = x;
                                        c3p2.y = y;
                                    }
                                    break;
                                default:
                                    {
                                    }
                                    break;
                            }
                            latestCurveMode = CurvePointMode.P2;
                        }
                        break;
                    case VertexCmd.P3c:
                        {
                            //this is p3c
                            switch (latestCurveMode)
                            {
                                case CurvePointMode.P2:
                                    {
                                        c3p2.x = x;
                                        c3p2.y = y;
                                    }
                                    break;
                                case CurvePointMode.P3:
                                    {
                                        // vxs.AddVertex(x, y, cmd);
                                        c4p3.x = x;
                                        c4p3.y = y;
                                        //m_curve4.MakeLines(vxs,
                                        //    lastX, lasty,
                                        //    c3p2.X, c3p2.Y,
                                        //    c4p2.x, c4p2.y,
                                        //    x, y);

                                        // vxs.AddVertex(x, y, cmd);

                                    }
                                    break;
                                case CurvePointMode.NotCurve:
                                    {
                                        c4p2.x = x;
                                        c4p2.y = y;
                                    }
                                    break;
                            }
                            latestCurveMode = CurvePointMode.P3;
                        }
                        break;
                    case VertexCmd.LineTo:
                        {
                            switch (latestCurveMode)
                            {
                                case CurvePointMode.P2:
                                    {
                                        m_curve3.MakeLines(vxs,
                                            lastX,
                                            lasty,
                                            c3p2.X,
                                            c3p2.Y,
                                            x,
                                            y);
                                    }
                                    break;
                                case CurvePointMode.P3:
                                    {
                                        //from curve4
                                        // vxs.AddVertex(x, y, cmd);
                                        m_curve4.MakeLines(vxs,
                                            lastX, lasty,
                                            c4p2.x, c4p2.y,
                                            c4p3.x, c4p3.y,
                                            x, y);
                                    }
                                    break;
                                default:
                                    {
                                        vxs.AddVertex(x, y, cmd);
                                    }
                                    break;
                            }
                            //-----------
                            latestCurveMode = CurvePointMode.NotCurve;
                            lastX = x;
                            lasty = y;
                            //-----------
                        }
                        break;
                    case VertexCmd.MoveTo:
                        {
                            //move to, and end command
                            vxs.AddVertex(x, y, cmd);
                            //-----------
                            latestCurveMode = CurvePointMode.NotCurve;
                            lastMoveX = lastX = x;
                            lastMoveY = lasty = y;
                            //-----------
                        }
                        break;
                    case VertexCmd.CloseAndEndFigure:
                        {
                            latestCurveMode = CurvePointMode.NotCurve;
                            vxs.AddVertex(x, y, cmd);
                            //move to begin 
                            lastX = lastMoveX;
                            lasty = lastMoveY;
                        }
                        break;
                    case VertexCmd.EndFigure:
                        {
                            latestCurveMode = CurvePointMode.NotCurve;
                            vxs.AddVertex(x, y, cmd);
                        }
                        break;
                    default:
                        {
                            //move to, and end command
                            vxs.AddVertex(x, y, cmd);
                            //-----------
                            latestCurveMode = CurvePointMode.NotCurve;
                            lastX = x;
                            lasty = y;
                            //-----------
                        }
                        break;
                }
            } while (cmd != VertexCmd.Stop);

        }
Пример #36
0
 public static RectInt GetBoundingRect(VertexStoreSnap vs)
 {
     int x1, y1, x2, y2;
     bool rValue = GetBoundingRect(vs, out x1, out y1, out x2, out y2);
     return new RectInt(x1, y1, x2, y2);
 }
Пример #37
0
 //-----------------------------------------------------bounding_rect_single
 //template<class VertexSource, class CoordT> 
 static bool GetBoundingRect(
   VertexStoreSnap vs,
   out int x1, out int y1,
   out int x2, out int y2)
 {
     double x_d = 0;
     double y_d = 0;
     int x = 0;
     int y = 0;
     bool first = true;
     x1 = 1;
     y1 = 1;
     x2 = 0;
     y2 = 0;
     var vsnapIter = vs.GetVertexSnapIter();
     VertexCmd PathAndFlags;
     while (!VertexHelper.IsEmpty(PathAndFlags = vsnapIter.GetNextVertex(out x_d, out y_d)))
     {
         x = (int)x_d;
         y = (int)y_d;
         if (VertexHelper.IsVertextCommand(PathAndFlags))
         {
             if (first)
             {
                 x1 = x;
                 y1 = y;
                 x2 = x;
                 y2 = y;
                 first = false;
             }
             else
             {
                 if (x < x1) x1 = x;
                 if (y < y1) y1 = y;
                 if (x > x2) x2 = x;
                 if (y > y2) y2 = y;
             }
         }
     }
     return x1 <= x2 && y1 <= y2;
 }
Пример #38
0
 public Contour(VertexStoreSnap vertexSource)
 {
     this.generator = new ContourGenerator();
     this.vertexSource = vertexSource;
 }
Пример #39
0
        void AddPath(VertexStoreSnap s)
        {
            double x;
            double y;
            VertexCmd cmd;
            var snapIter = s.GetVertexSnapIter();
            while ((cmd = snapIter.GetNextVertex(out x, out y)) != VertexCmd.Stop)
            {
                AddVertex(x, y, cmd);
            }



            Render(false);
        }
Пример #40
0
 public void RenderVertexSnap(VertexStoreSnap s, Drawing.Color c)
 {
     m_ren.Color = c;
     AddPath(s);
 }
Пример #41
0
 public VertexStore TransformToVxs(VertexStoreSnap snap, VertexStore vxs)
 {
     var vsnapIter = snap.GetVertexSnapIter();
     double x, y;
     VertexCmd cmd;
     do
     {
         cmd = vsnapIter.GetNextVertex(out x, out y);
         this.Transform(ref x, ref y);
         vxs.AddVertex(x, y, cmd);
     } while (!VertexHelper.IsEmpty(cmd));
     return vxs;
 }
Пример #42
0
 public AggRenderVx(VertexStoreSnap snap)
 {
     this.snap = snap;
 }
Пример #43
0
 //// Concatenate path. The path is added as is.
 public void ConcatPath(VertexStoreSnap s)
 {
     double x, y;
     VertexCmd cmd_flags;
     var snapIter = s.GetVertexSnapIter();
     while ((cmd_flags = snapIter.GetNextVertex(out x, out y)) != VertexCmd.Stop)
     {
         myvxs.AddVertex(x, y, cmd_flags);
     }
 }
Пример #44
0
 /// <summary>
 /// we do NOT store vxs, return original outputVxs
 /// </summary>
 /// <param name="src"></param>
 /// <param name="outputVxs"></param>
 /// <returns></returns>
 public VertexStore TransformToVxs(VertexStoreSnap src, VertexStore outputVxs)
 {
     var snapIter = src.GetVertexSnapIter();
     VertexCmd cmd;
     double x, y;
     while ((cmd = snapIter.GetNextVertex(out x, out y)) != VertexCmd.Stop)
     {
         this.Transform(ref x, ref y);
         outputVxs.AddVertex(x, y, cmd);
     }
     return outputVxs;
 }