23 public void render(Vector2f loc,
float minR,
float maxR, Color color,
boolean spiral,
float factor,
float alphaMult) {
25 float middleRadius = minR + (maxR - minR) / 2f;
26 middleRadius *= factor;
30 float circ = (float) (Math.PI * 2f * middleRadius);
31 float pixelsPerSegment = 5f;
33 float segments = Math.round(circ / pixelsPerSegment);
35 float startRad = (float) Math.toRadians(0);
36 float endRad = (float) Math.toRadians(360f);
37 float spanRad = Misc.normalizeAngle(endRad - startRad);
38 float anglePerSegment = spanRad / segments;
44 GL11.glTranslatef(x * factor, y * factor, 0);
45 GL11.glRotatef(angle, 0, 0, 1);
47 GL11.glEnable(GL11.GL_TEXTURE_2D);
48 texture.bindTexture();
51 GL11.glEnable(GL11.GL_BLEND);
52 GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
54 GL11.glColor4ub((
byte)color.getRed(),
55 (byte)color.getGreen(),
56 (byte)color.getBlue(),
57 (byte)((
float) color.getAlpha() * alphaMult));
60 float texWidth = texture.getTextureWidth();
61 float imageWidth = texture.getWidth();
62 float bandWidthInTexture = imageWidth;
64 float thickness = (maxR - minR) * 1f * factor;
65 float radius = middleRadius - thickness / 2f;
67 float prev = (radius + thickness);
68 thickness = Math.min(thickness, (radius + thickness) * 0.25f);
69 radius = prev - thickness;
72 float texProgress = 0f;
73 float texHeight = texture.getTextureHeight();
74 float imageHeight = texture.getHeight();
75 float texPerSegment = pixelsPerSegment * texHeight / imageHeight * bandWidthInTexture / thickness;
78 float totalTex = Math.max(1f, Math.round(texPerSegment * segments));
79 texPerSegment = totalTex / segments;
88 float minSpiralRadius = radius * 0.01f;
89 float spiralFactor = 1.25f;
93 GL11.glBegin(GL11.GL_QUAD_STRIP);
96 for (
float i = 0; i < segments; i++) {
97 float theta = anglePerSegment * i;
98 float cos = (float) Math.cos(theta);
99 float sin = (float) Math.sin(theta);
100 float x1 = cos * radius;
101 float y1 = sin * radius;
102 float x2 = cos * (radius + thickness);
103 float y2 = sin * (radius + thickness);
105 GL11.glTexCoord2f(leftTX, texProgress);
106 GL11.glVertex2f(x1, y1);
107 GL11.glTexCoord2f(rightTX, texProgress);
108 GL11.glVertex2f(x2, y2);
110 texProgress += texPerSegment;
115 float theta = anglePerSegment * i;
116 float cos = (float) Math.cos(theta);
117 float sin = (float) Math.sin(theta);
118 float x1 = cos * radius;
119 float y1 = sin * radius;
120 float x2 = cos * (radius + thickness);
121 float y2 = sin * (radius + thickness);
123 GL11.glTexCoord2f(leftTX, texProgress);
124 GL11.glVertex2f(x1, y1);
125 GL11.glTexCoord2f(rightTX, texProgress);
126 GL11.glVertex2f(x2, y2);
131 float numSpirals = (radius - minSpiralRadius) / (thickness * spiralFactor);
132 if (numSpirals < 2) numSpirals = 2;
134 float thicknessMult = 10f;
136 for (
float i = 0; i < segments * numSpirals; i++) {
137 distMult = 1f - (i / (segments * numSpirals));
139 distMult = (float) Math.sqrt(distMult);
142 float alpha = i / segments;
143 if (i > segments * (numSpirals - 1)) {
144 alpha = (segments * numSpirals - i) / segments;
146 if (alpha > 1) alpha = 1;
147 if (alpha < 0) alpha = 0;
149 GL11.glColor4ub((
byte)color.getRed(),
150 (byte)color.getGreen(),
151 (byte)color.getBlue(),
152 (byte)((
float) color.getAlpha() * alpha * alphaMult));
155 theta = anglePerSegment * i;
156 float cos = (float) Math.cos(theta);
157 float sin = (float) Math.sin(theta);
158 float x1 = cos * ((radius - minSpiralRadius) * distMult + minSpiralRadius);
159 float y1 = sin * ((radius - minSpiralRadius) * distMult + minSpiralRadius);
160 float x2 = cos * (((radius - minSpiralRadius) * distMult + thickness * thicknessMult) + minSpiralRadius);
161 float y2 = sin * (((radius - minSpiralRadius) * distMult + thickness * thicknessMult) + minSpiralRadius);
163 GL11.glTexCoord2f(leftTX, texProgress);
164 GL11.glVertex2f(x1, y1);
165 GL11.glTexCoord2f(rightTX, texProgress);
166 GL11.glVertex2f(x2, y2);
168 float circumferenceMult = ((radius - minSpiralRadius) * distMult + minSpiralRadius) / radius;
169 texProgress += texPerSegment * circumferenceMult;
172 GL11.glColor4ub((
byte)color.getRed(),
173 (byte)color.getGreen(),
174 (byte)color.getBlue(),
175 (byte)((
float) color.getAlpha() * alphaMult));