示例#1
0
        /// <summary>
        /// Creates a position matrix (in pixels) based on the position of a cell.
        /// </summary>
        /// <param name="position">The cell position.</param>
        /// <param name="cellSize">The size of the cell in pixels.</param>
        /// <param name="absolutePositioning">When true, indicates that the <paramref name="position"/> indicates pixels, not cell coordinates.</param>
        /// <returns>A matrix for rendering.</returns>
        public static Matrix ToPositionMatrix(this Point position, Point cellSize, bool absolutePositioning)
        {
            Point worldLocation;

            if (absolutePositioning)
            {
                worldLocation = position;
            }
            else
            {
                worldLocation = position.ConsoleLocationToWorld(cellSize.X, cellSize.Y);
            }

            var matrix = new Matrix();

            matrix.Translate(worldLocation.X, worldLocation.Y);
            return(matrix);
        }
示例#2
0
        /// <summary>
        /// Gets the cell coordinates of the <paramref name="targetFont"/> based on a cell in the <paramref name="sourceFont"/>.
        /// </summary>
        /// <param name="point">The position of the cell in the <paramref name="sourceFont"/>.</param>
        /// <param name="sourceFont">The source font translating from.</param>
        /// <param name="targetFont">The target font translating to.</param>
        /// <returns>The position of the cell in the <paramref name="targetFont"/>.</returns>
        public static Point TranslateFont(this Point point, SadFont sourceFont, SadFont targetFont)
        {
            var world = point.ConsoleLocationToWorld(sourceFont.Size.X, sourceFont.Size.Y);

            return(world.WorldLocationToConsole(targetFont.Size.X, targetFont.Size.Y));
        }