Beispiel #1
0
        public static void SendShapeToTesselator(VertexTesselatorAbstract tesselator, IVertexSource vertexSource)
        {
#if !DEBUG
            try
#endif
            {
                tesselator.BeginPolygon();

                ShapePath.FlagsAndCommand PathAndFlags = 0;
                double x, y;
                bool   haveBegunContour = false;
                while (!ShapePath.is_stop(PathAndFlags = vertexSource.vertex(out x, out y)))
                {
                    if (ShapePath.is_close(PathAndFlags) ||
                        (haveBegunContour && ShapePath.is_move_to(PathAndFlags)))
                    {
                        tesselator.EndContour();
                        haveBegunContour = false;
                    }

                    if (!ShapePath.is_close(PathAndFlags))
                    {
                        if (!haveBegunContour)
                        {
                            tesselator.BeginContour();
                            haveBegunContour = true;
                        }

                        tesselator.AddVertex(x, y);
                    }
                }

                if (haveBegunContour)
                {
                    tesselator.EndContour();
                }

                tesselator.EndPolygon();
            }
#if !DEBUG
            catch
            {
            }
#endif
        }
Beispiel #2
0
        // Behavior which relies on classic IVertexSource.vertex iteration
        private static RectangleDouble GetCharacterBounds(char character, StyledTypeFace typeface)
        {
            IVertexSource glyphForCharacter = typeface.GetGlyphForCharacter(character, 1);

            glyphForCharacter.rewind(0);

            ShapePath.FlagsAndCommand curCommand;

            var bounds = RectangleDouble.ZeroIntersection;

            do
            {
                curCommand = glyphForCharacter.vertex(out double x, out double y);

                if (curCommand != ShapePath.FlagsAndCommand.Stop &&
                    !ShapePath.is_close(curCommand))
                {
                    bounds.ExpandToInclude(x, y);
                }
            } while (curCommand != ShapePath.FlagsAndCommand.Stop);

            return(bounds);
        }