private static IList ScaleAndTransformStrokes()

in WindowsSmartInk/Microsoft.MTC.SmartInk/Extensions/InkStrokeCollectionExtensions.cs [135:166]


        private static IList<InkStroke> ScaleAndTransformStrokes(IList<InkStroke> strokeList, float scale, float rotation = 0)
        {
            var builder = new InkStrokeBuilder();
            IList<InkStroke> rotatedStrokes;
            IList<InkStroke> translatedStrokes = new List<InkStroke>();
            var rotationMatrix = Matrix3x2.CreateRotation(ConvertDegreesToRadians(rotation));
            var scaleMatrix = Matrix3x2.CreateScale(scale);

            if (rotation != 0)
            {
                rotatedStrokes = new List<InkStroke>();
                foreach (var stroke in strokeList)
                {
                    var newStroke = builder.CreateStrokeFromInkPoints(stroke.GetInkPoints(), rotationMatrix);
                    rotatedStrokes.Add(newStroke);
                }
            }
            else
                rotatedStrokes = strokeList;

            var boundingBox = (rotation != 0) ? rotatedStrokes.GetBoundingBox() : strokeList.GetBoundingBox(); ;
            var translateMatrix = Matrix3x2.CreateTranslation((float)-boundingBox.X, (float)-boundingBox.Y);
           
            foreach (var stroke in rotatedStrokes)
            {
                
                var newStroke = builder.CreateStrokeFromInkPoints(stroke.GetInkPoints(), rotationMatrix * translateMatrix * scaleMatrix);
                translatedStrokes.Add(newStroke);
            }

            return translatedStrokes;
        }