Avalonia.Controls.PanAndZoom.MatrixHelper.ScaleAt C# (CSharp) Method

ScaleAt() public static method

Creates a matrix that is scaling from a specified center.
public static ScaleAt ( double scaleX, double scaleY, double centerX, double centerY ) : Avalonia.Matrix
scaleX double Scaling factor that is applied along the x-axis.
scaleY double Scaling factor that is applied along the y-axis.
centerX double The center X-coordinate of the scaling.
centerY double The center Y-coordinate of the scaling.
return Avalonia.Matrix
        public static Matrix ScaleAt(double scaleX, double scaleY, double centerX, double centerY)
        {
            return new Matrix(scaleX, 0, 0, scaleY, centerX - scaleX * centerX, centerY - scaleY * centerY);
        }

Usage Example

Ejemplo n.º 1
0
        /// <summary>
        /// Calculate pan and zoom matrix based on provided streatch mode.
        /// </summary>
        /// <param name="panelWidth">The panel width.</param>
        /// <param name="panelHeight">The panel height.</param>
        /// <param name="elementWidth">The element width.</param>
        /// <param name="elementHeight">The element height.</param>
        /// <param name="mode">The stretch mode.</param>
        public static Matrix CalculateMatrix(double panelWidth, double panelHeight, double elementWidth, double elementHeight, StretchMode mode)
        {
            var zx = panelWidth / elementWidth;
            var zy = panelHeight / elementHeight;
            var cx = elementWidth / 2.0;
            var cy = elementHeight / 2.0;

            switch (mode)
            {
            default:
            case StretchMode.None:
                return(Matrix.Identity);

            case StretchMode.Fill:
                return(MatrixHelper.ScaleAt(zx, zy, cx, cy));

            case StretchMode.Uniform:
            {
                var zoom = Min(zx, zy);
                return(MatrixHelper.ScaleAt(zoom, zoom, cx, cy));
            }

            case StretchMode.UniformToFill:
            {
                var zoom = Max(zx, zy);
                return(MatrixHelper.ScaleAt(zoom, zoom, cx, cy));
            }
            }
        }
All Usage Examples Of Avalonia.Controls.PanAndZoom.MatrixHelper::ScaleAt