ScaleAt() публичный статический Метод

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.
Результат Avalonia.Matrix
Пример #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));
            }
            }
        }
Пример #2
0
        public void Fill(Rect panelSize, Rect elementSize)
        {
            if (_element != null)
            {
                double pw = panelSize.Width;
                double ph = panelSize.Height;
                double ew = elementSize.Width;
                double eh = elementSize.Height;
                double zx = pw / ew;
                double zy = ph / eh;

                _matrix = MatrixHelper.ScaleAt(zx, zy, ew / 2.0, eh / 2.0);

                Invalidate();
            }
        }
Пример #3
0
        public void Extent(Rect panelSize, Rect elementSize)
        {
            if (_element != null)
            {
                double pw   = panelSize.Width;
                double ph   = panelSize.Height;
                double ew   = elementSize.Width;
                double eh   = elementSize.Height;
                double zx   = pw / ew;
                double zy   = ph / eh;
                double zoom = Min(zx, zy);
                double cx   = ew / 2.0;
                double cy   = eh / 2.0;

                _matrix = MatrixHelper.ScaleAt(zoom, zoom, cx, cy);

                Invalidate();
            }
        }