Skip to content
This repository was archived by the owner on Feb 19, 2019. It is now read-only.

Commit 515989e

Browse files
committed
Fixed Rectangle methods
1 parent 740d713 commit 515989e

File tree

1 file changed

+28
-4
lines changed

1 file changed

+28
-4
lines changed

src/main/java/me/zero/client/api/util/render/RenderUtils.java

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,18 @@ public static void drawReflectedTexturedRect(float x1, float y1, float x2, float
200200
public static void rectangle(float x1, float y1, float x2, float y2, int color) {
201201
GlUtils.glColor(color);
202202

203+
if (x1 > x2) {
204+
float temp = x1;
205+
x1 = x2;
206+
x2 = temp;
207+
}
208+
209+
if (y1 > y2) {
210+
float temp = y1;
211+
y1 = y2;
212+
y2 = temp;
213+
}
214+
203215
setupRender(true);
204216
setupClientState(GLClientState.VERTEX, true);
205217
tessellator.addVertex(x1, y2, 0).addVertex(x2, y2, 0).addVertex(x2, y1, 0).addVertex(x1, y1, 0).draw(GL_QUADS);
@@ -235,10 +247,10 @@ private static void rectangleGradient(float x1, float y1, float x2, float y2, in
235247

236248
if (color.length == 1) {
237249
c1 = color[0];
238-
c2 = color[1];
239-
c3 = color[2];
240-
c4 = color[3];
241-
} else if (color.length > 1 && color.length < 4) {
250+
c2 = color[0];
251+
c3 = color[0];
252+
c4 = color[0];
253+
} else if (color.length < 4) {
242254
c1 = color[0];
243255
c2 = color[0];
244256
c3 = color[1];
@@ -250,6 +262,18 @@ private static void rectangleGradient(float x1, float y1, float x2, float y2, in
250262
c4 = color[3];
251263
}
252264

265+
if (x1 > x2) {
266+
float temp = x1;
267+
x1 = x2;
268+
x2 = temp;
269+
}
270+
271+
if (y1 > y2) {
272+
float temp = y1;
273+
y1 = y2;
274+
y2 = temp;
275+
}
276+
253277
setupRender(true);
254278
OpenGlHelper.glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, 1, 0);
255279
GlStateManager.shadeModel(GL_FLAT);

0 commit comments

Comments
 (0)