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