public PathMeasure(Path path) { _originalPathIterator = new CachedPathIteratorFactory(new FullPathIterator(path)); _path = path; _geometry = _path.GetGeometry(CanvasDevice.GetSharedDevice()); Length = _geometry.ComputePathLength(); }
private void RecreateGeometry(ICanvasResourceCreator resourceCreator) { leftGeometry = CreateGeometry(resourceCreator, LeftGeometryType); rightGeometry = CreateGeometry(resourceCreator, RightGeometryType); if (enableTransform) { Matrix3x2 placeNearOrigin = Matrix3x2.CreateTranslation(-200, -200); Matrix3x2 undoPlaceNearOrigin = Matrix3x2.CreateTranslation(200, 200); Matrix3x2 rotate0 = Matrix3x2.CreateRotation((float)Math.PI / 4.0f); // 45 degrees Matrix3x2 scale0 = Matrix3x2.CreateScale(1.5f); Matrix3x2 rotate1 = Matrix3x2.CreateRotation((float)Math.PI / 6.0f); // 30 degrees Matrix3x2 scale1 = Matrix3x2.CreateScale(2.0f); leftGeometry = leftGeometry.Transform(placeNearOrigin * rotate0 * scale0 * undoPlaceNearOrigin); rightGeometry = rightGeometry.Transform(placeNearOrigin * rotate1 * scale1 * undoPlaceNearOrigin); } combinedGeometry = leftGeometry.CombineWith(rightGeometry, interGeometryTransform, WhichCombineType); if (UseFillOrStroke == FillOrStroke.Stroke) { CanvasStrokeStyle strokeStyle = new CanvasStrokeStyle(); strokeStyle.DashStyle = CanvasDashStyle.Dash; combinedGeometry = combinedGeometry.Stroke(15.0f, strokeStyle); } totalDistanceOnContourPath = combinedGeometry.ComputePathLength(); if (showTessellation) { tessellation = combinedGeometry.Tessellate(); } }