Bubbles3/Controls/BblImageSurface.cs
/// <summary>
/// Get the bounding rect of rect transformed by transform
/// works for any rotation
/// </summary>
/// <param name="rect">the rectangle to transform</param>
/// <param name="boundingRect">the bounding rectangle output</param>
/// <param name="transform">the transform to apply</param>
Get the bounding rect of rect transformed by transform
works for any rotation
Get the bounding rect of rect transformed by transform works for any rotation
private void TransformedBounds(RectangleF rect, out RectangleF boundingRect, Matrix3x2 transform)
        {
            Vector2 tl = Matrix3x2.TransformPoint(transform, rect.TopLeft);
            Vector2 tr = Matrix3x2.TransformPoint(transform, rect.TopRight);
            Vector2 bl = Matrix3x2.TransformPoint(transform, rect.BottomLeft);
            Vector2 br = Matrix3x2.TransformPoint(transform, rect.BottomRight);
            float t = Math.Min(Math.Min(tl.Y, tr.Y), Math.Min(bl.Y, br.Y));
            float b = Math.Max(Math.Max(tl.Y, tr.Y), Math.Max(bl.Y, br.Y));
            float l = Math.Min(Math.Min(tl.X, tr.X), Math.Min(bl.X, br.X));
            float r = Math.Max(Math.Max(tl.X, tr.X), Math.Max(bl.X, br.X));
            boundingRect = new RectangleF(l, t, (r - l), (b - t));
        }
private void TransformedBounds ( RectangleF rect , out RectangleF boundingRect , Matrix3x2 transform ) { Vector2 tl = Matrix3x2 . TransformPoint ( transform , rect . TopLeft ) ; Vector2 tr = Matrix3x2 . TransformPoint ( transform , rect . TopRight ) ; Vector2 bl = Matrix3x2 . TransformPoint ( transform , rect . BottomLeft ) ; Vector2 br = Matrix3x2 . TransformPoint ( transform , rect . BottomRight ) ; float t = Math . Min ( Math . Min ( tl . Y , tr . Y ) , Math . Min ( bl . Y , br . Y ) ) ; float b = Math . Max ( Math . Max ( tl . Y , tr . Y ) , Math . Max ( bl . Y , br . Y ) ) ; float l = Math . Min ( Math . Min ( tl . X , tr . X ) , Math . Min ( bl . X , br . X ) ) ; float r = Math . Max ( Math . Max ( tl . X , tr . X ) , Math . Max ( bl . X , br . X ) ) ; boundingRect = new RectangleF ( l , t , ( r - l ) , ( b - t ) ) ; }
Get the bounding rect of rect transformed by transform
works for any rotation
Get the bounding rect of rect transformed by transform works for any rotation
rect
RectangleF
the rectangle to transform
the rectangle to transform
RectangleF
out
transform
Matrix3x2
the transform to apply
the transform to apply
boundingRect
the bounding rectangle output
the bounding rectangle output