public static void SplitGrid (object tex, int gridx, int gridy, Rectangle sheetrect) {
        bool gappy = false;
        if (gridx < 0) {
            gridx = -gridx;
            gridy = -gridy;
            gappy = true;
        }

        list = new STex[gridx * gridy];

        int cellwidth = sheetrect.Width / gridx;
        int cellheight = sheetrect.Height / gridy;

        for (int y = 0; y < gridy; y++) {
            for (int x = 0; x < gridx; x++) {
                int sheetx = sheetrect.X + x * cellwidth;
                int sheety = sheetrect.Y + y * cellheight;
                Rectangle rect = new Rectangle(sheetx, sheety, cellwidth, cellheight);
                if (gappy) {
                    rect.X += 1;
                    rect.Y += 1;
                    rect.Width -= 2;
                    rect.Height -= 2;
                }
                list[y * gridx + x] = new STex(tex, rect);
            }
        }
    }
    public static void SplitGrid(object tex, int gridx, int gridy, Rectangle sheetrect)
    {
        bool gappy = false;

        if (gridx < 0)
        {
            gridx = -gridx;
            gridy = -gridy;
            gappy = true;
        }

        list = new STex[gridx * gridy];

        int cellwidth  = sheetrect.Width / gridx;
        int cellheight = sheetrect.Height / gridy;

        for (int y = 0; y < gridy; y++)
        {
            for (int x = 0; x < gridx; x++)
            {
                int       sheetx = sheetrect.X + x * cellwidth;
                int       sheety = sheetrect.Y + y * cellheight;
                Rectangle rect   = new Rectangle(sheetx, sheety, cellwidth, cellheight);
                if (gappy)
                {
                    rect.X      += 1;
                    rect.Y      += 1;
                    rect.Width  -= 2;
                    rect.Height -= 2;
                }
                list[y * gridx + x] = new STex(tex, rect);
            }
        }
    }