public static Matrix GetStrokeTransform(SceneElement element) { Matrix matrix = new Matrix(); ShapeElement shapeElement = element as ShapeElement; if (shapeElement != null) { Rect computedTightBounds = shapeElement.GetComputedTightBounds(); double strokeWidth = BrushAdorner.GetStrokeWidth(element); double scaleX = computedTightBounds.Width == 0.0 ? 1.0 : 1.0 - strokeWidth / computedTightBounds.Width; double scaleY = computedTightBounds.Height == 0.0 ? 1.0 : 1.0 - strokeWidth / computedTightBounds.Height; matrix.Translate(-0.5, -0.5); matrix.Scale(scaleX, scaleY); matrix.Translate(0.5, 0.5); } return(matrix); }