TerrificTable55

Untitled

Oct 22nd, 2022
920
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.88 KB | None | 0 0
  1.     public static void drawRect(double left, double top, double right, double bottom, int colorr) {
  2.        drawRect(left, top, right, bottom, new Color(colorr));
  3.     }
  4.  
  5.     public static void drawRect(double left, double top, double right, double bottom, Color colorr)
  6.     {
  7.         int color = colorr.hashCode();
  8.         right = left + right;
  9.         bottom = top + bottom;
  10.  
  11.            if (left < right)
  12.             {
  13.                 double i = left;
  14.                 left = right;
  15.                 right = i;
  16.             }
  17.  
  18.             if (top < bottom)
  19.             {
  20.                 double j = top;
  21.                 top = bottom;
  22.                 bottom = j;
  23.             }
  24.  
  25.             float f3 = (float)(color >> 24 & 255) / 255.0F;
  26.             float f = (float)(color >> 16 & 255) / 255.0F;
  27.             float f1 = (float)(color >> 8 & 255) / 255.0F;
  28.             float f2 = (float)(color & 255) / 255.0F;
  29.             Tessellator tessellator = Tessellator.getInstance();
  30.             WorldRenderer worldrenderer = tessellator.getWorldRenderer();
  31.             GlStateManager.enableBlend();
  32.             GlStateManager.disableTexture2D();
  33.             GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0);
  34.             GlStateManager.color(f, f1, f2, f3);
  35.             worldrenderer.begin(7, DefaultVertexFormats.POSITION);
  36.             worldrenderer.pos((double)left, (double)bottom, 0.0D).endVertex();
  37.             worldrenderer.pos((double)right, (double)bottom, 0.0D).endVertex();
  38.             worldrenderer.pos((double)right, (double)top, 0.0D).endVertex();
  39.             worldrenderer.pos((double)left, (double)top, 0.0D).endVertex();
  40.             tessellator.draw();
  41.             GlStateManager.enableTexture2D();
  42.             GlStateManager.disableBlend();
  43.     }
  44.  
  45.     public static void drawOutline(float x, float y, float width, float height, int lineWidth, Color color) {
  46.  
  47.         glPushMatrix();
  48.         glEnable(GL_BLEND);
  49.         glDisable(GL_TEXTURE_2D);
  50.         glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
  51.         glEnable(GL_LINE_SMOOTH);
  52.         glLineWidth(lineWidth);
  53.  
  54.         glColor3f(color.getRed()/255F, color.getGreen()/255F, color.getBlue()/255F);
  55.  
  56.  
  57.         // ------
  58.         //
  59.         // -    -
  60.         glBegin(GL_LINE_STRIP);
  61.         glVertex2d(x, y);
  62.         glVertex2d(width, y);
  63.         glEnd();
  64.  
  65.         // -    -
  66.         // |
  67.         // -    -
  68.         glBegin(GL_LINE_STRIP);
  69.         glVertex2d(x, y);
  70.         glVertex2d(x, height);
  71.         glEnd();
  72.  
  73.         // -    -
  74.         //      |
  75.         // -    -
  76.         glBegin(GL_LINE_STRIP);
  77.         glVertex2d(width, y);
  78.         glVertex2d(width, height);
  79.         glEnd();
  80.  
  81.         // -    -
  82.         //
  83.         // ------
  84.         glBegin(GL_LINE_STRIP);
  85.         glVertex2d(x, height);
  86.         glVertex2d(width, height);
  87.         glEnd();
  88.  
  89.  
  90.         glEnable(GL_TEXTURE_2D);
  91.         glDisable(GL_BLEND);
  92.         glDisable(GL_LINE_SMOOTH);
  93.         GlStateManager.resetColor();
  94.         glPopMatrix();
  95.     }
Advertisement
Add Comment
Please, Sign In to add comment