예제 #1
0
 /// <summary>
 /// Creates a matrix that rotates about a specified center.
 /// </summary>
 /// <param name="angle">Angle of rotation in radians.</param>
 /// <param name="center">The center of the rotation.</param>
 /// <returns>The created rotation matrix.</returns>
 public static Matrix Rotation(double angle, Vector center)
 {
     return
         Matrix.CreateTranslation(-center)
         * Matrix.CreateRotation(angle)
         * Matrix.CreateTranslation(center);
 }
예제 #2
0
        /// <summary>
        /// Gets the root of the control's visual tree and the position of the control 
        /// in the root's coordinate space.
        /// </summary>
        /// <param name="v">The visual.</param>
        /// <returns>A tuple containing the root and the position of the control.</returns>
        private static Tuple<IRenderRoot, Vector> GetRootAndPosition(IVisual v)
        {
            var result = new Vector();

            while (!(v is IRenderRoot))
            {
                result = new Vector(result.X + v.Bounds.X, result.Y + v.Bounds.Y);
                v = v.VisualParent;

                if (v == null)
                {
                    throw new InvalidOperationException("Control is not attached to visual tree.");
                }
            }

            return Tuple.Create((IRenderRoot)v, result);
        }
예제 #3
0
파일: Visual.cs 프로젝트: KvanTTT/Perspex
        /// <summary>
        /// Gets the visual offset from the specified ancestor.
        /// </summary>
        /// <param name="ancestor">The ancestor visual.</param>
        /// <param name="visual">The visual.</param>
        /// <returns>The visual offset.</returns>
        private static Vector GetOffsetFrom(IVisual ancestor, IVisual visual)
        {
            var result = new Vector();

            while (visual != ancestor)
            {
                result = new Vector(result.X + visual.Bounds.X, result.Y + visual.Bounds.Y);
                visual = visual.VisualParent;

                if (visual == null)
                {
                    throw new ArgumentException("'visual' is not a descendent of 'ancestor'.");
                }
            }

            return result;
        }
예제 #4
0
 public static Matrix Translation(Vector v)
 {
     return Translation(v.X, v.Y);
 }
예제 #5
0
 public static Matrix Scaling(Vector scale)
 {
     return new Matrix(scale.X, 0, 0, scale.Y, 0, 0);
 }
예제 #6
0
파일: Rect.cs 프로젝트: KvanTTT/Perspex
 /// <summary>
 /// Translates the rectangle by an offset.
 /// </summary>
 /// <param name="offset">The offset.</param>
 /// <returns>The translated rectangle.</returns>
 public Rect Translate(Vector offset)
 {
     return new Rect(Position + offset, Size);
 }
예제 #7
0
파일: Matrix.cs 프로젝트: Scellow/Perspex
 /// <summary>
 /// Creates a translation matrix from the given vector.
 /// </summary>
 /// <param name="position">The translation position.</param>
 /// <returns>A translation matrix.</returns>
 public static Matrix CreateTranslation(Vector position)
 {
     return CreateTranslation(position.X, position.Y);
 }
예제 #8
0
파일: Matrix.cs 프로젝트: Scellow/Perspex
 /// <summary>
 /// Creates a scale matrix from the given vector scale.
 /// </summary>
 /// <param name="scales">The scale to use.</param>
 /// <returns>A scaling matrix.</returns>
 public static Matrix CreateScale(Vector scales)
 {
     return new Matrix(scales.X, 0, 0, scales.Y, 0, 0);
 }