Advertisement
Olivki

[MC] Better GUI methods. [/MC]

Jul 16th, 2012
1,575
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 8.23 KB | None | 0 0
  1.     public static void drawRect(float g, float h, float i, float j, int col1) {
  2.         float f = (float)(col1 >> 24 & 0xFF) / 255F;
  3.         float f1 = (float)(col1 >> 16 & 0xFF) / 255F;
  4.         float f2 = (float)(col1 >> 8 & 0xFF) / 255F;
  5.         float f3 = (float)(col1 & 0xFF) / 255F;
  6.  
  7.         GL11.glEnable(GL11.GL_BLEND);
  8.         GL11.glDisable(GL11.GL_TEXTURE_2D);
  9.         GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
  10.         GL11.glEnable(GL11.GL_LINE_SMOOTH);
  11.  
  12.         GL11.glPushMatrix();
  13.         GL11.glColor4f(f1, f2, f3, f);
  14.         GL11.glBegin(GL11.GL_QUADS);
  15.         GL11.glVertex2d(i, h);
  16.         GL11.glVertex2d(g, h);
  17.         GL11.glVertex2d(g, j);
  18.         GL11.glVertex2d(i, j);
  19.         GL11.glEnd();
  20.         GL11.glPopMatrix();
  21.  
  22.         GL11.glEnable(GL11.GL_TEXTURE_2D);
  23.         GL11.glDisable(GL11.GL_BLEND);
  24.         GL11.glDisable(GL11.GL_LINE_SMOOTH);
  25.     }
  26.  
  27.     public static void drawGradientRect(int x, int y, int x2, int y2, int col1, int col2) {
  28.         float f = (float)(col1 >> 24 & 0xFF) / 255F;
  29.         float f1 = (float)(col1 >> 16 & 0xFF) / 255F;
  30.         float f2 = (float)(col1 >> 8 & 0xFF) / 255F;
  31.         float f3 = (float)(col1 & 0xFF) / 255F;
  32.  
  33.         float f4 = (float)(col2 >> 24 & 0xFF) / 255F;
  34.         float f5 = (float)(col2 >> 16 & 0xFF) / 255F;
  35.         float f6 = (float)(col2 >> 8 & 0xFF) / 255F;
  36.         float f7 = (float)(col2 & 0xFF) / 255F;
  37.  
  38.         GL11.glEnable(GL11.GL_BLEND);
  39.         GL11.glDisable(GL11.GL_TEXTURE_2D);
  40.         GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
  41.         GL11.glEnable(GL11.GL_LINE_SMOOTH);
  42.         GL11.glShadeModel(GL11.GL_SMOOTH);
  43.  
  44.         GL11.glPushMatrix();
  45.         GL11.glBegin(GL11.GL_QUADS);
  46.         GL11.glColor4f(f1, f2, f3, f);
  47.         GL11.glVertex2d(x2, y);
  48.         GL11.glVertex2d(x, y);
  49.  
  50.         GL11.glColor4f(f5, f6, f7, f4);
  51.         GL11.glVertex2d(x, y2);
  52.         GL11.glVertex2d(x2, y2);
  53.         GL11.glEnd();
  54.         GL11.glPopMatrix();
  55.  
  56.         GL11.glEnable(GL11.GL_TEXTURE_2D);
  57.         GL11.glDisable(GL11.GL_BLEND);
  58.         GL11.glDisable(GL11.GL_LINE_SMOOTH);
  59.         GL11.glShadeModel(GL11.GL_FLAT);
  60.     }
  61.  
  62.     public static void drawSideGradientRect(float x, float y, float x2, float y2, int col1, int col2) {
  63.         float f = (float)(col1 >> 24 & 0xFF) / 255F;
  64.         float f1 = (float)(col1 >> 16 & 0xFF) / 255F;
  65.         float f2 = (float)(col1 >> 8 & 0xFF) / 255F;
  66.         float f3 = (float)(col1 & 0xFF) / 255F;
  67.  
  68.         float f4 = (float)(col2 >> 24 & 0xFF) / 255F;
  69.         float f5 = (float)(col2 >> 16 & 0xFF) / 255F;
  70.         float f6 = (float)(col2 >> 8 & 0xFF) / 255F;
  71.         float f7 = (float)(col2 & 0xFF) / 255F;
  72.  
  73.         GL11.glEnable(GL11.GL_BLEND);
  74.         GL11.glDisable(GL11.GL_TEXTURE_2D);
  75.         GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
  76.         GL11.glEnable(GL11.GL_LINE_SMOOTH);
  77.         GL11.glShadeModel(GL11.GL_SMOOTH);
  78.  
  79.         GL11.glPushMatrix();
  80.         GL11.glBegin(GL11.GL_QUADS);
  81.         GL11.glColor4f(f1, f2, f3, f);
  82.         GL11.glVertex2d(x2, y);
  83.  
  84.         GL11.glColor4f(f5, f6, f7, f4);
  85.         GL11.glVertex2d(x, y);
  86.         GL11.glVertex2d(x, y2);
  87.  
  88.         GL11.glColor4f(f1, f2, f3, f);
  89.         GL11.glVertex2d(x2, y2);
  90.         GL11.glEnd();
  91.         GL11.glPopMatrix();
  92.  
  93.         GL11.glEnable(GL11.GL_TEXTURE_2D);
  94.         GL11.glDisable(GL11.GL_BLEND);
  95.         GL11.glDisable(GL11.GL_LINE_SMOOTH);
  96.         GL11.glShadeModel(GL11.GL_FLAT);
  97.     }
  98.  
  99.     public static void drawBorderedRect(int x, int y, int x2, int y2, float l1, int col1, int col2) {
  100.         drawRect(x, y, x2, y2, col2);
  101.  
  102.         float f = (float)(col1 >> 24 & 0xFF) / 255F;
  103.         float f1 = (float)(col1 >> 16 & 0xFF) / 255F;
  104.         float f2 = (float)(col1 >> 8 & 0xFF) / 255F;
  105.         float f3 = (float)(col1 & 0xFF) / 255F;
  106.  
  107.         GL11.glEnable(GL11.GL_BLEND);
  108.         GL11.glDisable(GL11.GL_TEXTURE_2D);
  109.         GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
  110.         GL11.glEnable(GL11.GL_LINE_SMOOTH);
  111.  
  112.         GL11.glPushMatrix();
  113.         GL11.glColor4f(f1, f2, f3, f);
  114.         GL11.glLineWidth(l1);
  115.         GL11.glBegin(GL11.GL_LINES);
  116.         GL11.glVertex2d(x, y);
  117.         GL11.glVertex2d(x, y2);
  118.         GL11.glVertex2d(x2, y2);
  119.         GL11.glVertex2d(x2, y);
  120.         GL11.glVertex2d(x, y);
  121.         GL11.glVertex2d(x2, y);
  122.         GL11.glVertex2d(x, y2);
  123.         GL11.glVertex2d(x2, y2);
  124.         GL11.glEnd();
  125.         GL11.glPopMatrix();
  126.  
  127.         GL11.glEnable(GL11.GL_TEXTURE_2D);
  128.         GL11.glDisable(GL11.GL_BLEND);
  129.         GL11.glDisable(GL11.GL_LINE_SMOOTH);
  130.     }
  131.  
  132.     public static void drawHollowBorderedRect(int x, int y, int x2, int y2, float l1, int col1) {
  133.         float f = (float)(col1 >> 24 & 0xFF) / 255F;
  134.         float f1 = (float)(col1 >> 16 & 0xFF) / 255F;
  135.         float f2 = (float)(col1 >> 8 & 0xFF) / 255F;
  136.         float f3 = (float)(col1 & 0xFF) / 255F;
  137.  
  138.         GL11.glEnable(GL11.GL_BLEND);
  139.         GL11.glDisable(GL11.GL_TEXTURE_2D);
  140.         GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
  141.         GL11.glEnable(GL11.GL_LINE_SMOOTH);
  142.  
  143.         GL11.glPushMatrix();
  144.         GL11.glColor4f(f1, f2, f3, f);
  145.         GL11.glLineWidth(l1);
  146.         GL11.glBegin(GL11.GL_LINES);
  147.         GL11.glVertex2d(x, y);
  148.         GL11.glVertex2d(x, y2);
  149.         GL11.glVertex2d(x2, y2);
  150.         GL11.glVertex2d(x2, y);
  151.         GL11.glVertex2d(x, y);
  152.         GL11.glVertex2d(x2, y);
  153.         GL11.glVertex2d(x, y2);
  154.         GL11.glVertex2d(x2, y2);
  155.         GL11.glEnd();
  156.         GL11.glPopMatrix();
  157.  
  158.         GL11.glEnable(GL11.GL_TEXTURE_2D);
  159.         GL11.glDisable(GL11.GL_BLEND);
  160.         GL11.glDisable(GL11.GL_LINE_SMOOTH);
  161.     }
  162.  
  163.     public static void drawGradientBorderedRect(int x, int y, int x2, int y2, float l1, int col1, int col2, int col3) {
  164.         drawGradientRect(x, y, x2, y2, col2, col3);
  165.  
  166.         float f = (float)(col1 >> 24 & 0xFF) / 255F;
  167.         float f1 = (float)(col1 >> 16 & 0xFF) / 255F;
  168.         float f2 = (float)(col1 >> 8 & 0xFF) / 255F;
  169.         float f3 = (float)(col1 & 0xFF) / 255F;
  170.  
  171.         GL11.glEnable(GL11.GL_BLEND);
  172.         GL11.glDisable(GL11.GL_TEXTURE_2D);
  173.         GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
  174.         GL11.glEnable(GL11.GL_LINE_SMOOTH);
  175.  
  176.         GL11.glPushMatrix();
  177.         GL11.glColor4f(f1, f2, f3, f);
  178.         GL11.glLineWidth(l1);
  179.         GL11.glBegin(GL11.GL_LINES);
  180.         GL11.glVertex2d(x, y);
  181.         GL11.glVertex2d(x, y2);
  182.         GL11.glVertex2d(x2, y2);
  183.         GL11.glVertex2d(x2, y);
  184.         GL11.glVertex2d(x, y);
  185.         GL11.glVertex2d(x2, y);
  186.         GL11.glVertex2d(x, y2);
  187.         GL11.glVertex2d(x2, y2);
  188.         GL11.glEnd();
  189.         GL11.glPopMatrix();
  190.  
  191.         GL11.glEnable(GL11.GL_TEXTURE_2D);
  192.         GL11.glDisable(GL11.GL_BLEND);
  193.         GL11.glDisable(GL11.GL_LINE_SMOOTH);
  194.     }
  195.  
  196.     public static void drawVerticalLine(int x, int y, int y2, float l1, int col1) {
  197.         float f = (float)(col1 >> 24 & 0xFF) / 255F;
  198.         float f1 = (float)(col1 >> 16 & 0xFF) / 255F;
  199.         float f2 = (float)(col1 >> 8 & 0xFF) / 255F;
  200.         float f3 = (float)(col1 & 0xFF) / 255F;
  201.  
  202.         GL11.glEnable(GL11.GL_BLEND);
  203.         GL11.glDisable(GL11.GL_TEXTURE_2D);
  204.         GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
  205.         GL11.glEnable(GL11.GL_LINE_SMOOTH);
  206.  
  207.         GL11.glPushMatrix();
  208.         GL11.glColor4f(f1, f2, f3, f);
  209.         GL11.glLineWidth(l1);
  210.         GL11.glBegin(GL11.GL_LINES);
  211.         GL11.glVertex2d(x, y);
  212.         GL11.glVertex2d(x, y2);
  213.         GL11.glEnd();
  214.         GL11.glPopMatrix();
  215.  
  216.         GL11.glEnable(GL11.GL_TEXTURE_2D);
  217.         GL11.glDisable(GL11.GL_BLEND);
  218.         GL11.glDisable(GL11.GL_LINE_SMOOTH);
  219.     }
  220.  
  221.     public static void drawHorizontalLine(int x, int x2, int y, float l1, int col1) {
  222.         float f = (float)(col1 >> 24 & 0xFF) / 255F;
  223.         float f1 = (float)(col1 >> 16 & 0xFF) / 255F;
  224.         float f2 = (float)(col1 >> 8 & 0xFF) / 255F;
  225.         float f3 = (float)(col1 & 0xFF) / 255F;
  226.  
  227.         GL11.glEnable(GL11.GL_BLEND);
  228.         GL11.glDisable(GL11.GL_TEXTURE_2D);
  229.         GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
  230.         GL11.glEnable(GL11.GL_LINE_SMOOTH);
  231.  
  232.         GL11.glPushMatrix();
  233.         GL11.glColor4f(f1, f2, f3, f);
  234.         GL11.glLineWidth(l1);
  235.         GL11.glBegin(GL11.GL_LINES);
  236.         GL11.glVertex2d(x, y);
  237.         GL11.glVertex2d(x2, y);
  238.         GL11.glEnd();
  239.         GL11.glPopMatrix();
  240.  
  241.         GL11.glEnable(GL11.GL_TEXTURE_2D);
  242.         GL11.glDisable(GL11.GL_BLEND);
  243.         GL11.glDisable(GL11.GL_LINE_SMOOTH);
  244.     }
  245.  
  246.     public static void drawDiagonalLine(int x, int x2, int y, float l1, int col1) {
  247.         float f = (float)(col1 >> 24 & 0xFF) / 255F;
  248.         float f1 = (float)(col1 >> 16 & 0xFF) / 255F;
  249.         float f2 = (float)(col1 >> 8 & 0xFF) / 255F;
  250.         float f3 = (float)(col1 & 0xFF) / 255F;
  251.  
  252.         GL11.glEnable(GL11.GL_BLEND);
  253.         GL11.glDisable(GL11.GL_TEXTURE_2D);
  254.         GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
  255.         GL11.glEnable(GL11.GL_LINE_SMOOTH);
  256.  
  257.         GL11.glPushMatrix();
  258.         GL11.glColor4f(f1, f2, f3, f);
  259.         GL11.glLineWidth(l1);
  260.         GL11.glBegin(GL11.GL_LINES);
  261.         GL11.glVertex2d(x, y);
  262.         GL11.glVertex2d(y, x2);
  263.         GL11.glEnd();
  264.         GL11.glPopMatrix();
  265.  
  266.         GL11.glEnable(GL11.GL_TEXTURE_2D);
  267.         GL11.glDisable(GL11.GL_BLEND);
  268.         GL11.glDisable(GL11.GL_LINE_SMOOTH);
  269.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement