コード例 #1
0
ファイル: term-lib.cs プロジェクト: Unknown6656/kiezellisp
        internal static void CheckBounds(ref int x, ref int y, ref int w, ref int h, int width, int height)
        {
            if (x == -1)
            {
                Runtime.Assert(0 < w && w <= width, "Invalid w");
                x = (width - w) / 2;
            }
            else if (w == 0)
            {
                Runtime.Assert(0 <= x && x < width, "Invalid x");
                w = width - x;
            }
            else
            {
                Runtime.Assert(0 <= x && x < width, "Invalid x");
                Runtime.Assert(0 < w && w <= width, "Invalid w");
                Runtime.Assert(x + w <= width, "Invalid x+w");
            }

            if (y == -1)
            {
                Runtime.Assert(0 < h && h <= height, "Invalid h");
                y = (height - h) / 2;
            }
            else if (h == 0)
            {
                Runtime.Assert(0 <= y && y < height, "Invalid y");
                h = height - h;
            }
            else
            {
                Runtime.Assert(0 <= y && y < height, "Invalid y");
                Runtime.Assert(0 < h && h <= height, "Invalid h");
                Runtime.Assert(y + h <= height, "Invalid y+h");
            }
        }