Beispiel #1
0
        public void ZoomByScaleFactor(SKPoint point, float scaleFactor)
        {
            var currentScale = GetScale();

            currentScale *= scaleFactor;
            if (currentScale < MinScale || currentScale > MaxScale)
            {
                return;
            }
            if (!CenterBoundary.IsEmpty)
            {
                var center = GetCenter();
                if (!CenterBoundary.Contains(center))
                {
                    return;
                }
            }
            SKMatrix.PreConcat(ref Matrix, SKMatrix.MakeScale(scaleFactor, scaleFactor, point.X, point.Y));
        }
Beispiel #2
0
        public void MoveByVector(SKPoint vector)
        {
            SKMatrix invertedMatrix;

            if (!Matrix.TryInvert(out invertedMatrix))
            {
                return;
            }
            var resultPoint = invertedMatrix.MapVector(vector.X, vector.Y);

            SKMatrix.PreConcat(ref Matrix, SKMatrix.MakeTranslation(resultPoint.X, resultPoint.Y));
            if (CenterBoundary.IsEmpty)
            {
                return;
            }
            var center = GetCenter();

            if (!CenterBoundary.Contains(center))
            {
                //rollback
                SKMatrix.PreConcat(ref Matrix, SKMatrix.MakeTranslation(-resultPoint.X, -resultPoint.Y));
            }
        }