コード例 #1
0
        public GlyphFitOutline Analyze(GlyphPointF[] glyphPoints, ushort[] glyphContours)
        {
            var glyphToCountor = new GlyphTranslatorToContour();

            glyphToCountor.Read(glyphPoints, glyphContours);
            //master outline analysis
            List <GlyphContour> contours = glyphToCountor.GetContours(); //analyzed contour
            int j        = contours.Count;
            var analyzer = new GlyphPartAnalyzer();

            analyzer.NSteps = 4;

            for (int i = 0; i < j; ++i)
            {
                contours[i].Analyze(analyzer);
            }

            if (j > 0)
            {
                return(TessWithPolyTri(contours));
            }
            else
            {
                return(null);
            }
        }
コード例 #2
0
        public void Analyze(GlyphPartAnalyzer analyzer)
        {
            if (analyzed)
            {
                return;
            }
            //
            //---------------
            //http://stackoverflow.com/questions/1165647/how-to-determine-if-a-list-of-polygon-points-are-in-clockwise-order
            //check if hole or not
            //clockwise or counter-clockwise
            {
                //Some of the suggested methods will fail in the case of a non-convex polygon, such as a crescent.
                //Here's a simple one that will work with non-convex polygons (it'll even work with a self-intersecting polygon like a figure-eight, telling you whether it's mostly clockwise).

                //Sum over the edges, (x2 − x1)(y2 + y1).
                //If the result is positive the curve is clockwise,
                //if it's negative the curve is counter-clockwise. (The result is twice the enclosed area, with a +/- convention.)
                int   j     = allPoints.Count;
                float total = 0;
                for (int i = 3; i < j; ++i)
                {
                    float x0 = allPoints[i - 3];
                    float y0 = allPoints[i - 2];
                    float x1 = allPoints[i - 1];
                    float y1 = allPoints[i];

                    total += (x1 - x0) * (y1 + y0);
                    i     += 2;
                }
                //the last one
                {
                    float x0 = allPoints[j - 2];
                    float y0 = allPoints[j - 1];
                    float x1 = allPoints[0];
                    float y1 = allPoints[1];
                    total += (x1 - x0) * (y1 + y0);
                }

                isClockwise = total >= 0;
            }

            //flatten each part ...
            //-------------------------------
            {
                int j = parts.Count;
                //---------------
                for (int i = 0; i < j; ++i)
                {
                    parts[i].Analyze(analyzer);
                }
            }


            analyzed = true;
        }
コード例 #3
0
 public override void Analyze(GlyphPartAnalyzer analyzer)
 {
     points = new List <GlyphPoint2D>();
     analyzer.CreateBezierVxs3(
         analyzer.NSteps,
         points,
         new Vector2(x0, y0),
         new Vector2(x, y),
         new Vector2(p2x, p2y));
 }
コード例 #4
0
        public void Hint(GlyphPointF[] glyphPoints, ushort[] glyphContours, float pxScale = 1)
        {
            this.pxScale = pxScale;
            var analyzer1 = new GlyphContourReader();

            analyzer1.Read(glyphPoints, glyphContours);
            //master outline analysis
            contours = analyzer1.GetContours();
            int j        = contours.Count;
            var analyzer = new GlyphPartAnalyzer();

            analyzer.NSteps     = 4;
            analyzer.PixelScale = pxScale;
            for (int i = 0; i < j; ++i)
            {
                contours[i].Analyze(analyzer);
            }

            glyphOutline = TessWithPolyTri(contours, pxScale);
        }
コード例 #5
0
 public override void Analyze(GlyphPartAnalyzer analyzer)
 {
     points = new List <GlyphPoint2D>();
     points.Add(new GlyphPoint2D(x0, y0, PointKind.LineStart));
     points.Add(new GlyphPoint2D(x1, y1, PointKind.LineStop));
 }
コード例 #6
0
 public abstract void Analyze(GlyphPartAnalyzer analyzer);