Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void drawRoundedRect(float x0, float y0, float x1, float y1, float radiusTopLeft, float radiusTopRight, float radiusBottomLeft, float radiusBottomRight, int color)
- {
- int numberOfArcs = 18;
- float angleIncrement = 90.0F / numberOfArcs;
- float a = (color >> 24 & 0xFF) / 255.0F;
- float r = (color >> 16 & 0xFF) / 255.0F;
- float g = (color >> 8 & 0xFF) / 255.0F;
- float b = (color & 0xFF) / 255.0F;
- GL11.glDisable(2884);
- GL11.glDisable(3553);
- GL11.glEnable(3042);
- GL11.glBlendFunc(770, 771);
- OpenGlHelper.glBlendFunc(770, 771, 1, 0);
- GL11.glColor4f(r, g, b, a);
- GL11.glBegin(5);
- GL11.glVertex2f(x0 + radiusTopLeft, y0);
- GL11.glVertex2f(x0 + radiusBottomLeft, y1);
- GL11.glVertex2f(x1 - radiusTopRight, y0);
- GL11.glVertex2f(x1 - radiusBottomRight, y1);
- GL11.glEnd();
- GL11.glBegin(5);
- GL11.glVertex2f(x0, y0 + radiusTopLeft);
- GL11.glVertex2f(x0 + radiusTopLeft, y0 + radiusTopLeft);
- GL11.glVertex2f(x0, y1 - radiusBottomLeft);
- GL11.glVertex2f(x0 + radiusBottomLeft, y1 - radiusBottomLeft);
- GL11.glEnd();
- GL11.glBegin(5);
- GL11.glVertex2f(x1, y0 + radiusTopRight);
- GL11.glVertex2f(x1 - radiusTopRight, y0 + radiusTopRight);
- GL11.glVertex2f(x1, y1 - radiusBottomRight);
- GL11.glVertex2f(x1 - radiusBottomRight, y1 - radiusBottomRight);
- GL11.glEnd();
- GL11.glBegin(6);
- float centerX = x1 - radiusTopRight;
- float centerY = y0 + radiusTopRight;
- GL11.glVertex2f(centerX, centerY);
- for (int i = 0; i <= numberOfArcs; i++)
- {
- float angle = i * angleIncrement;
- GL11.glVertex2f((float)(centerX + radiusTopRight * Math.cos(Math.toRadians(angle))), (float)(centerY - radiusTopRight * Math.sin(Math.toRadians(angle))));
- }
- GL11.glEnd();
- GL11.glBegin(6);
- centerX = x0 + radiusTopLeft;
- centerY = y0 + radiusTopLeft;
- GL11.glVertex2f(centerX, centerY);
- for (int i = 0; i <= numberOfArcs; i++)
- {
- float angle = i * angleIncrement;
- GL11.glVertex2f((float)(centerX - radiusTopLeft * Math.cos(Math.toRadians(angle))), (float)(centerY - radiusTopLeft * Math.sin(Math.toRadians(angle))));
- }
- GL11.glEnd();
- GL11.glBegin(6);
- centerX = x0 + radiusBottomLeft;
- centerY = y1 - radiusBottomLeft;
- GL11.glVertex2f(centerX, centerY);
- for (int i = 0; i <= numberOfArcs; i++)
- {
- float angle = i * angleIncrement;
- GL11.glVertex2f((float)(centerX - radiusBottomLeft * Math.cos(Math.toRadians(angle))), (float)(centerY + radiusBottomLeft * Math.sin(Math.toRadians(angle))));
- }
- GL11.glEnd();
- GL11.glBegin(6);
- centerX = x1 - radiusBottomRight;
- centerY = y1 - radiusBottomRight;
- GL11.glVertex2f(centerX, centerY);
- for (int i = 0; i <= numberOfArcs; i++)
- {
- float angle = i * angleIncrement;
- GL11.glVertex2f((float)(centerX + radiusBottomRight * Math.cos(Math.toRadians(angle))), (float)(centerY + radiusBottomRight * Math.sin(Math.toRadians(angle))));
- }
- GL11.glEnd();
- GL11.glEnable(3553);
- GL11.glEnable(2884);
- GL11.glDisable(3042);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement