localToParentCoordinates() public method

Transforms the specified point in the element's coordinates to be in the parent's coordinates.
public localToParentCoordinates ( Vector2 localCoords ) : Vector2
localCoords Vector2 Local coords.
return Vector2
Esempio n. 1
0
        /// <summary>
        /// Converts coordinates for this element to those of a parent element. The ascendant does not need to be a direct parent
        /// </summary>
        /// <returns>The to ascendant coordinates.</returns>
        /// <param name="ascendant">Ascendant.</param>
        /// <param name="localCoords">Local coords.</param>
        public Vector2 localToAscendantCoordinates(Element ascendant, Vector2 localCoords)
        {
            Element element = this;

            while (element != null)
            {
                localCoords = element.localToParentCoordinates(localCoords);
                element     = element.parent;
                if (element == ascendant)
                {
                    break;
                }
            }
            return(localCoords);
        }