Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static void drawRectangleRepeated(int x, int y, float u, float v, float uMax, float vMax, int width, int height, int tileWidth, int tileHeight, int zLevel)
- {
- float uvHeight = v - vMax;
- int numX = (int) Math.ceil((float) width / tileWidth);
- int numY = (int) Math.ceil((float) height / tileHeight);
- for (int y2 = 0; y2 < numY; ++y2)
- for (int x2 = 0; x2 < numX; ++x2)
- {
- int w = tileWidth;
- int h = tileHeight;
- float tileMaxU = uMax;
- float tileMaxV = vMax;
- float tileV = v;
- int tileX = w * x2;
- int tileY = h * y2 + h;
- if (tileWidth > width)
- {
- w = width;
- tileMaxU -= 0.00390625F * (float) w / tileWidth;
- tileX = w * x2;
- }
- else if (x2 == numX - 1)
- {
- if (tileWidth > width - x2 * tileWidth)
- {
- w = width - x2 * tileWidth;
- tileMaxU -= 0.00390625F * (float) w / tileWidth;
- tileX = tileWidth * x2;
- }
- }
- if (tileHeight > height)
- {
- h = height;
- tileMaxV -= 0.00390625F * (float) h / tileHeight;
- tileY = h * y2 + h;
- }
- else if (y2 == numY - 1)
- {
- if (tileHeight > height - (y2 - 1) * tileHeight)
- {
- h = height - (y2 - 1) * tileHeight;
- tileV += uvHeight - 0.00390625F * (float) h / tileHeight;
- tileY = tileHeight * y2 + h;
- }
- }
- drawRectangleStretched(x + tileX, y + height - tileY, u, tileV, w, h, tileMaxU, tileMaxV, zLevel);
- }
- }
- public static void drawRectangleXRepeated(int x, int y, float u, float v, float uMax, float vMax, int width, int height, int tileWidth, int zLevel)
- {
- float uvHeight = v - vMax;
- int numX = (int) Math.ceil((float) width / tileWidth);
- for (int x2 = 0; x2 < numX; ++x2)
- {
- int w = tileWidth;
- float tileMaxU = uMax;
- int tileX = w * x2;
- if (tileWidth > width)
- {
- w = width;
- tileMaxU -= 0.00390625F * (float) w / tileWidth;
- tileX = w * x2;
- }
- else if (x2 == numX - 1)
- {
- if (tileWidth > width - x2 * tileWidth)
- {
- w = width - x2 * tileWidth;
- tileMaxU -= 0.00390625F * (float) w / tileWidth;
- tileX = tileWidth * x2;
- }
- }
- drawRectangleStretched(x + tileX, y, u, v, w, height, tileMaxU, vMax, zLevel);
- }
- }
- public static void drawRectangleYRepeated(int x, int y, float u, float v, float uMax, float vMax, int width, int height, int tileHeight, int zLevel)
- {
- float uvHeight = v - vMax;
- int numY = (int) Math.ceil((float) height / tileHeight);
- for (int y2 = 0; y2 < numY; ++y2)
- {
- int h = tileHeight;
- float tileMaxV = vMax;
- float tileV = v;
- int tileY = h * y2 + h;
- if (tileHeight > height)
- {
- h = height;
- tileMaxV -= 0.00390625F * (float) h / tileHeight;
- tileY = h * y2 + h;
- }
- else if (y2 == numY - 1)
- {
- if (tileHeight > height - (y2 - 1) * tileHeight)
- {
- h = height - (y2 - 1) * tileHeight;
- tileV += uvHeight - 0.00390625F * (float) h / tileHeight;
- tileY = tileHeight * y2 + h;
- }
- }
- drawRectangleStretched(x, y + height - tileY, u, tileV, width, h, uMax, tileMaxV, zLevel);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement