コード例 #1
0
ファイル: Matrix.cs プロジェクト: sung-su/maui
        internal static void TransformRect(ref Microsoft.Maui.Graphics.Rect rect, ref Matrix matrix)
        {
            if (rect.IsEmpty)
            {
                return;
            }

            MatrixTypes matrixType = matrix._type;

            if (matrixType == MatrixTypes.Identity)
            {
                return;
            }

            // Scaling
            if (0 != (matrixType & MatrixTypes.Scaling))
            {
                rect.X      *= matrix._m11;
                rect.Y      *= matrix._m22;
                rect.Width  *= matrix._m11;
                rect.Height *= matrix._m22;

                if (rect.Width < 0.0)
                {
                    rect.X    += rect.Width;
                    rect.Width = -rect.Width;
                }

                if (rect.Height < 0.0)
                {
                    rect.Y     += rect.Height;
                    rect.Height = -rect.Height;
                }
            }

            // Translation
            if (0 != (matrixType & MatrixTypes.Translation))
            {
                // X
                rect.X += matrix._offsetX;

                // Y
                rect.X += matrix._offsetY;
            }

            if (matrixType == MatrixTypes.Unknown)
            {
                Point point0 = matrix.Transform(new Point(rect.Right, rect.Top));
                Point point1 = matrix.Transform(new Point(rect.Right, rect.Top));
                Point point2 = matrix.Transform(new Point(rect.Right, rect.Bottom));
                Point point3 = matrix.Transform(new Point(rect.Left, rect.Bottom));

                rect.X = Math.Min(Math.Min(point0.X, point1.X), Math.Min(point2.X, point3.X));
                rect.Y = Math.Min(Math.Min(point0.Y, point1.Y), Math.Min(point2.Y, point3.Y));

                rect.Width  = Math.Max(Math.Max(point0.X, point1.X), Math.Max(point2.X, point3.X)) - rect.X;
                rect.Height = Math.Max(Math.Max(point0.Y, point1.Y), Math.Max(point2.Y, point3.Y)) - rect.Y;
            }
        }
コード例 #2
0
 public override void PlatformArrange(Rect frame)
 {
     base.PlatformArrange(frame);
     VisualElementRenderer.UpdateLayout();
 }
コード例 #3
0
 public static ERect ToPixel(this Rect rect)
 {
     return(new ERect(Forms.ConvertToScaledPixel(rect.X), Forms.ConvertToScaledPixel(rect.Y), Forms.ConvertToScaledPixel(rect.Width), Forms.ConvertToScaledPixel(rect.Height)));
 }
コード例 #4
0
 /// <include file="../../../docs/Microsoft.Maui.Controls.Shapes/RoundRectangleGeometry.xml" path="//Member[@MemberName='.ctor'][2]/Docs" />
 public RoundRectangleGeometry(CornerRadius cornerRadius, Rect rect)
 {
     CornerRadius = cornerRadius;
     Rect         = rect;
 }