예제 #1
0
        public override Task Rebuild()
        {
            this.DebugDepth("Rebuild");
            using (RebuildLock())
            {
                double pointsToMm = 0.352778;

                var printer = new TypeFacePrinter(Text.Value(this), new StyledTypeFace(ApplicationController.GetTypeFace(Font), PointSize.Value(this)))
                {
                    ResolutionScale = 10
                };

                var scaledLetterPrinter = new VertexSourceApplyTransform(printer, Affine.NewScaling(pointsToMm));
                var vertexSource        = new VertexStorage();

                foreach (var vertex in scaledLetterPrinter.Vertices())
                {
                    if (vertex.IsMoveTo)
                    {
                        vertexSource.MoveTo(vertex.position);
                    }
                    else if (vertex.IsLineTo)
                    {
                        vertexSource.LineTo(vertex.position);
                    }
                    else if (vertex.IsClose)
                    {
                        vertexSource.ClosePolygon();
                    }
                }

                vertexSource = (VertexStorage)vertexSource.Union(vertexSource);

                this.VertexSource = vertexSource;

                // set the mesh to show the path
                this.Mesh = this.VertexSource.Extrude(Constants.PathPolygonsHeight);
            }

            Parent?.Invalidate(new InvalidateArgs(this, InvalidateType.Path));
            return(Task.CompletedTask);
        }