Exemple #1
0
        public int CompareTo(Object o)
        {
            int result = 0;

            if (o is FillPath)
            {
                FillPath co = (FillPath)o;
                if (this.FillStyle != co.FillStyle)
                {
                    result = this.FillStyle.CompareTo(co.FillStyle);
                }
                else if (this.Segment != co.Segment)
                {
                    result = this.Segment.CompareTo(co.Segment);
                }
            }
            else
            {
                throw new ArgumentException("Objects being compared are not of the same type");
            }
            return(result);
        }
Exemple #2
0
        /// <summary>
        /// The input strokes are all of the same stroke style, we put them tip to tail here, and discard dups.
        /// </summary>
        /// <param name="paths"></param>
        /// <returns></returns>
        private static DDW.Vex.Shape ConsolidatePaths(List <FillPath> ps)
        {
            // don't destroy org path
            //List<FillPath> ps = new List<FillPath>(paths);

            DDW.Vex.Shape result = new DDW.Vex.Shape();
            if (ps.Count == 0)
            {
                return(result);
            }
            result.Fill = ps[0].FillStyle;


            List <IShapeData> rs = result.ShapeData;

            rs.Add(ps[0].Segment);
            Point curStart = ps[0].Segment.StartPoint;
            Point curEnd   = ps[0].Segment.EndPoint;

            ps.RemoveAt(0);

            bool hasMatch = true;

            while (hasMatch && ps.Count > 0)
            {
                hasMatch = false;
                for (int i = 0; i < ps.Count; i++)
                {
                    if (ps[i].Segment.StartPoint == curEnd || ps[i].Segment.EndPoint == curEnd)
                    {
                        FillPath fp = ps[i];
                        ps.RemoveAt(i);

                        // in this case, the segment is backwards (this can happen in swf)
                        if (fp.Segment.EndPoint == curEnd)
                        {
                            fp.Segment.Reverse();
                        }
                        rs.Add(fp.Segment);
                        curEnd = fp.Segment.EndPoint;

                        hasMatch = true;
                        if (curEnd == curStart)
                        {
                            if (ps.Count > 0)
                            {
                                curStart = ps[0].Segment.StartPoint;
                                curEnd   = ps[0].Segment.EndPoint;
                                rs.Add(ps[0].Segment);
                                ps.RemoveAt(0);
                            }
                            else
                            {
                                hasMatch = false;
                            }
                        }

                        break;
                    }
                }
            }

            result.CalcuateBounds();

            return(result);
        }