Nez.Portable/UI/Base/Element.cs
/// <summary>
/// Transforms the specified point in the element's coordinates to be in the parent's coordinates.
/// </summary>
/// <returns>The to parent coordinates.</returns>
/// <param name="localCoords">Local coords.</param>
Transforms the specified point in the element's coordinates to be in the parent's coordinates.
Transforms the specified point in the element ' s coordinates to be in the parent ' s coordinates .
public Vector2 localToParentCoordinates(Vector2 localCoords)
        {
            var rotation = -this.rotation;
            if (rotation == 0)
            {
                if (scaleX == 1 && scaleY == 1)
                {
                    localCoords.X += x;
                    localCoords.Y += y;
                }
                else
                {
                    localCoords.X = (localCoords.X - originX) * scaleX + originX + x;
                    localCoords.Y = (localCoords.Y - originY) * scaleY + originY + y;
                }
            }
            else
            {
                var cos = Mathf.cos(MathHelper.ToRadians(rotation));
                var sin = Mathf.sin(MathHelper.ToRadians(rotation));
                var tox = (localCoords.X - originX) * scaleX;
                var toy = (localCoords.Y - originY) * scaleY;
                localCoords.X = (tox * cos + toy * sin) + originX + x;
                localCoords.Y = (tox * -sin + toy * cos) + originY + y;
            }
            return localCoords;
        }
public Vector2 localToParentCoordinates ( Vector2 localCoords ) { var rotation = - this . rotation ; if ( rotation == 0 ) { if ( scaleX == 1 && scaleY == 1 ) { localCoords . X += x ; localCoords . Y += y ; } else { localCoords . X = ( localCoords . X - originX ) * scaleX + originX + x ; localCoords . Y = ( localCoords . Y - originY ) * scaleY + originY + y ; } } else { var cos = Mathf . cos ( MathHelper . ToRadians ( rotation ) ) ; var sin = Mathf . sin ( MathHelper . ToRadians ( rotation ) ) ; var tox = ( localCoords . X - originX ) * scaleX ; var toy = ( localCoords . Y - originY ) * scaleY ; localCoords . X = ( tox * cos + toy * sin ) + originX + x ; localCoords . Y = ( tox * - sin + toy * cos ) + originY + y ; } return localCoords ; }
Transforms the specified point in the element's coordinates to be in the parent's coordinates.
Transforms the specified point in the element ' s coordinates to be in the parent ' s coordinates .
The to parent coordinates.
The to parent coordinates .
localCoords
Vector2
None