diff options
| author | ThatGravyBoat <thatgravyboat@gmail.com> | 2021-07-15 01:36:50 -0230 |
|---|---|---|
| committer | ThatGravyBoat <thatgravyboat@gmail.com> | 2021-07-15 01:36:50 -0230 |
| commit | 718740e85f48b57bf712a62f811cd4d34dd98450 (patch) | |
| tree | 8d3c7751cf684fe98e513010233f7b7b46e3e351 /src/main/java/com/thatgravyboat/skyblockhud/core | |
| parent | 89fa98d85546eb93064ce4a2b66e79341750b577 (diff) | |
| download | skyblockhud-718740e85f48b57bf712a62f811cd4d34dd98450.tar.gz skyblockhud-718740e85f48b57bf712a62f811cd4d34dd98450.tar.bz2 skyblockhud-718740e85f48b57bf712a62f811cd4d34dd98450.zip | |
Updated important locations
Updated Config System (Thanks Moulberry)
Added Trackers Back with kill trackers
Diffstat (limited to 'src/main/java/com/thatgravyboat/skyblockhud/core')
30 files changed, 1089 insertions, 901 deletions
diff --git a/src/main/java/com/thatgravyboat/skyblockhud/core/BackgroundBlur.java b/src/main/java/com/thatgravyboat/skyblockhud/core/BackgroundBlur.java index a9d9d5d..f143b97 100644 --- a/src/main/java/com/thatgravyboat/skyblockhud/core/BackgroundBlur.java +++ b/src/main/java/com/thatgravyboat/skyblockhud/core/BackgroundBlur.java @@ -18,19 +18,31 @@ import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.fml.common.eventhandler.EventPriority; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; import org.lwjgl.opengl.GL11; +import org.lwjgl.opengl.GL30; public class BackgroundBlur { - private static HashMap<Float, Framebuffer> blurOutput = new HashMap<>(); - private static HashMap<Float, Long> lastBlurUse = new HashMap<>(); + private static class OutputStuff { + public Framebuffer framebuffer; + public Shader blurShaderHorz = null; + public Shader blurShaderVert = null; + + public OutputStuff(Framebuffer framebuffer, Shader blurShaderHorz, Shader blurShaderVert) { + this.framebuffer = framebuffer; + this.blurShaderHorz = blurShaderHorz; + this.blurShaderVert = blurShaderVert; + } + } + + private static final HashMap<Float, OutputStuff> blurOutput = new HashMap<>(); + private static final HashMap<Float, Long> lastBlurUse = new HashMap<>(); private static long lastBlur = 0; - private static HashSet<Float> requestedBlurs = new HashSet<>(); + private static final HashSet<Float> requestedBlurs = new HashSet<>(); private static int fogColour = 0; private static boolean registered = false; - public static void registerListener() { - if (!registered) { + if(!registered) { registered = true; MinecraftForge.EVENT_BUS.register(new BackgroundBlur()); } @@ -57,17 +69,21 @@ public class BackgroundBlur { int width = Minecraft.getMinecraft().displayWidth; int height = Minecraft.getMinecraft().displayHeight; - Framebuffer output = blurOutput.computeIfAbsent( - blur, - k -> { - Framebuffer fb = new Framebuffer(width, height, false); - fb.setFramebufferFilter(GL11.GL_NEAREST); - return fb; - } - ); + OutputStuff output = blurOutput.computeIfAbsent(blur, k -> { + Framebuffer fb = new Framebuffer(width, height, false); + fb.setFramebufferFilter(GL11.GL_NEAREST); + return new OutputStuff(fb, null, null); + }); - output.framebufferWidth = output.framebufferTextureWidth = width; - output.framebufferHeight = output.framebufferTextureHeight = height; + if(output.framebuffer.framebufferWidth != width || output.framebuffer.framebufferHeight != height) { + output.framebuffer.createBindFramebuffer(width, height); + if(output.blurShaderHorz != null) { + output.blurShaderHorz.setProjectionMatrix(createProjectionMatrix(width, height)); + } + if(output.blurShaderVert != null) { + output.blurShaderVert.setProjectionMatrix(createProjectionMatrix(width, height)); + } + } blurBackground(output, blur); } @@ -89,7 +105,7 @@ public class BackgroundBlur { @SubscribeEvent(priority = EventPriority.HIGHEST) public void onScreenRender(RenderGameOverlayEvent.Pre event) { - if (event.type == RenderGameOverlayEvent.ElementType.ALL) { + if(event.type == RenderGameOverlayEvent.ElementType.ALL) { processBlurs(); } } @@ -102,8 +118,6 @@ public class BackgroundBlur { fogColour |= (int) (event.blue * 255) & 0xFF; } - private static Shader blurShaderHorz = null; - private static Shader blurShaderVert = null; private static Framebuffer blurOutputHorz = null; /** @@ -126,8 +140,8 @@ public class BackgroundBlur { return projMatrix; } - private static void blurBackground(Framebuffer output, float blurFactor) { - if (!OpenGlHelper.isFramebufferEnabled() || !OpenGlHelper.areShadersSupported()) return; + private static void blurBackground(OutputStuff output, float blurFactor) { + if(!OpenGlHelper.isFramebufferEnabled() || !OpenGlHelper.areShadersSupported()) return; int width = Minecraft.getMinecraft().displayWidth; int height = Minecraft.getMinecraft().displayHeight; @@ -139,47 +153,52 @@ public class BackgroundBlur { GlStateManager.loadIdentity(); GlStateManager.translate(0.0F, 0.0F, -2000.0F); - if (blurOutputHorz == null) { + if(blurOutputHorz == null) { blurOutputHorz = new Framebuffer(width, height, false); blurOutputHorz.setFramebufferFilter(GL11.GL_NEAREST); } - if (blurOutputHorz == null || output == null) { + if(blurOutputHorz == null || output == null) { return; } - if (blurOutputHorz.framebufferWidth != width || blurOutputHorz.framebufferHeight != height) { + if(blurOutputHorz.framebufferWidth != width || blurOutputHorz.framebufferHeight != height) { blurOutputHorz.createBindFramebuffer(width, height); - blurShaderHorz.setProjectionMatrix(createProjectionMatrix(width, height)); Minecraft.getMinecraft().getFramebuffer().bindFramebuffer(false); } - try { - blurShaderHorz = new Shader(Minecraft.getMinecraft().getResourceManager(), "blur", Minecraft.getMinecraft().getFramebuffer(), blurOutputHorz); - blurShaderHorz.getShaderManager().getShaderUniform("BlurDir").set(1, 0); - blurShaderHorz.setProjectionMatrix(createProjectionMatrix(width, height)); - } catch (Exception ignored) {} - try { - blurShaderVert = new Shader(Minecraft.getMinecraft().getResourceManager(), "blur", blurOutputHorz, output); - blurShaderVert.getShaderManager().getShaderUniform("BlurDir").set(0, 1); - blurShaderVert.setProjectionMatrix(createProjectionMatrix(width, height)); - } catch (Exception ignored) {} - if (blurShaderHorz != null && blurShaderVert != null) { - if (blurShaderHorz.getShaderManager().getShaderUniform("Radius") == null) { + if(output.blurShaderHorz == null) { + try { + output.blurShaderHorz = new Shader(Minecraft.getMinecraft().getResourceManager(), "blur", + output.framebuffer, blurOutputHorz); + output.blurShaderHorz.getShaderManager().getShaderUniform("BlurDir").set(1, 0); + output.blurShaderHorz.setProjectionMatrix(createProjectionMatrix(width, height)); + } catch(Exception ignored) { } + } + if(output.blurShaderVert == null) { + try { + output.blurShaderVert = new Shader(Minecraft.getMinecraft().getResourceManager(), "blur", + blurOutputHorz, output.framebuffer); + output.blurShaderVert.getShaderManager().getShaderUniform("BlurDir").set(0, 1); + output.blurShaderVert.setProjectionMatrix(createProjectionMatrix(width, height)); + } catch(Exception ignored) { } + } + if(output.blurShaderHorz != null && output.blurShaderVert != null) { + if(output.blurShaderHorz.getShaderManager().getShaderUniform("Radius") == null) { //Corrupted shader? return; } - blurShaderHorz.getShaderManager().getShaderUniform("Radius").set(blurFactor); - blurShaderVert.getShaderManager().getShaderUniform("Radius").set(blurFactor); + output.blurShaderHorz.getShaderManager().getShaderUniform("Radius").set(blurFactor); + output.blurShaderVert.getShaderManager().getShaderUniform("Radius").set(blurFactor); GL11.glPushMatrix(); - /*GL30.glBindFramebuffer(GL30.GL_READ_FRAMEBUFFER, Minecraft.getMinecraft().getFramebuffer().framebufferObject); - GL30.glBindFramebuffer(GL30.GL_DRAW_FRAMEBUFFER, output.framebufferObject); + GL30.glBindFramebuffer(GL30.GL_READ_FRAMEBUFFER, Minecraft.getMinecraft().getFramebuffer().framebufferObject); + GL30.glBindFramebuffer(GL30.GL_DRAW_FRAMEBUFFER, output.framebuffer.framebufferObject); GL30.glBlitFramebuffer(0, 0, width, height, - 0, 0, output.framebufferWidth, output.framebufferHeight, - GL11.GL_COLOR_BUFFER_BIT, GL11.GL_NEAREST);*/ + 0, 0, output.framebuffer.framebufferWidth, output.framebuffer.framebufferHeight, + GL11.GL_COLOR_BUFFER_BIT, GL11.GL_NEAREST); - blurShaderHorz.loadShader(0); - blurShaderVert.loadShader(0); + output.blurShaderHorz.loadShader(0); + output.blurShaderVert.loadShader(0); GlStateManager.enableDepth(); GL11.glPopMatrix(); @@ -208,9 +227,9 @@ public class BackgroundBlur { if (blurOutput.isEmpty()) return; - Framebuffer fb = blurOutput.get(blurStrength); - if (fb == null) { - fb = blurOutput.values().iterator().next(); + OutputStuff out = blurOutput.get(blurStrength); + if(out == null) { + out = blurOutput.values().iterator().next(); } float uMin = x / (float) screenWidth; @@ -220,10 +239,11 @@ public class BackgroundBlur { GlStateManager.depthMask(false); Gui.drawRect(x, y, x + blurWidth, y + blurHeight, fogColour); - fb.bindFramebufferTexture(); + out.framebuffer.bindFramebufferTexture(); GlStateManager.color(1f, 1f, 1f, 1f); RenderUtils.drawTexturedRect(x, y, blurWidth, blurHeight, uMin, uMax, vMin, vMax); - fb.unbindFramebufferTexture(); + out.framebuffer.unbindFramebufferTexture(); GlStateManager.depthMask(true); } + } diff --git a/src/main/java/com/thatgravyboat/skyblockhud/core/ChromaColour.java b/src/main/java/com/thatgravyboat/skyblockhud/core/ChromaColour.java index 3137153..b9f4e79 100644 --- a/src/main/java/com/thatgravyboat/skyblockhud/core/ChromaColour.java +++ b/src/main/java/com/thatgravyboat/skyblockhud/core/ChromaColour.java @@ -25,8 +25,9 @@ public class ChromaColour { int[] arr = new int[split.length]; - for (int i = 0; i < split.length; i++) { - arr[i] = Integer.parseInt(split[split.length - 1 - i], RADIX); + + for(int i=0; i<split.length; i++) { + arr[i] = Integer.parseInt(split[split.length-1-i], RADIX); } return arr; } @@ -39,7 +40,7 @@ public class ChromaColour { int a = d[3]; int chr = d[4]; - return ((a & 0xFF) << 24 | (r & 0xFF) << 16 | (g & 0xFF) << 8 | (b & 0xFF)); + return (a & 0xFF) << 24 | (r & 0xFF) << 16 | (g & 0xFF) << 8 | (b & 0xFF); } public static int getSpeed(String special) { @@ -47,16 +48,15 @@ public class ChromaColour { } public static float getSecondsForSpeed(int speed) { - return ((255 - speed) / 254f * (MAX_CHROMA_SECS - MIN_CHROMA_SECS) + MIN_CHROMA_SECS); + return (255-speed)/254f*(MAX_CHROMA_SECS-MIN_CHROMA_SECS)+MIN_CHROMA_SECS; } private static final int MIN_CHROMA_SECS = 1; private static final int MAX_CHROMA_SECS = 60; public static long startTime = -1; - public static int specialToChromaRGB(String special) { - if (startTime < 0) startTime = System.currentTimeMillis(); + if(startTime < 0) startTime = System.currentTimeMillis(); int[] d = decompose(special); int chr = d[4]; @@ -67,14 +67,14 @@ public class ChromaColour { float[] hsv = Color.RGBtoHSB(r, g, b, null); - if (chr > 0) { + if(chr > 0) { float seconds = getSecondsForSpeed(chr); - hsv[0] += (System.currentTimeMillis() - startTime) / 1000f / seconds; + hsv[0] += (System.currentTimeMillis()-startTime)/1000f/seconds; hsv[0] %= 1; - if (hsv[0] < 0) hsv[0] += 1; + if(hsv[0] < 0) hsv[0] += 1; } - return ((a & 0xFF) << 24 | (Color.HSBtoRGB(hsv[0], hsv[1], hsv[2]) & 0x00FFFFFF)); + return (a & 0xFF) << 24 | (Color.HSBtoRGB(hsv[0], hsv[1], hsv[2]) & 0x00FFFFFF); } public static int rotateHue(int argb, int degrees) { @@ -85,9 +85,11 @@ public class ChromaColour { float[] hsv = Color.RGBtoHSB(r, g, b, null); - hsv[0] += degrees / 360f; + hsv[0] += degrees/360f; hsv[0] %= 1; - return ((a & 0xFF) << 24 | (Color.HSBtoRGB(hsv[0], hsv[1], hsv[2]) & 0x00FFFFFF)); + return (a & 0xFF) << 24 | (Color.HSBtoRGB(hsv[0], hsv[1], hsv[2]) & 0x00FFFFFF); } + + } diff --git a/src/main/java/com/thatgravyboat/skyblockhud/core/GlScissorStack.java b/src/main/java/com/thatgravyboat/skyblockhud/core/GlScissorStack.java index 0e1694e..6f21e9a 100644 --- a/src/main/java/com/thatgravyboat/skyblockhud/core/GlScissorStack.java +++ b/src/main/java/com/thatgravyboat/skyblockhud/core/GlScissorStack.java @@ -1,14 +1,14 @@ package com.thatgravyboat.skyblockhud.core; -import java.util.LinkedList; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.ScaledResolution; import org.lwjgl.opengl.GL11; +import java.util.LinkedList; + public class GlScissorStack { private static class Bounds { - int left; int top; int right; @@ -27,10 +27,10 @@ public class GlScissorStack { right = Math.min(right, this.right); bottom = Math.min(bottom, this.bottom); - if (top > bottom) { + if(top > bottom) { top = bottom; } - if (left > right) { + if(left > right) { left = right; } @@ -40,39 +40,39 @@ public class GlScissorStack { public void set(ScaledResolution scaledResolution) { int height = Minecraft.getMinecraft().displayHeight; int scale = scaledResolution.getScaleFactor(); - GL11.glScissor(left * scale, height - bottom * scale, (right - left) * scale, (bottom - top) * scale); + GL11.glScissor(left*scale, height-bottom*scale, (right-left)*scale, (bottom-top)*scale); } } private static final LinkedList<Bounds> boundsStack = new LinkedList<>(); public static void push(int left, int top, int right, int bottom, ScaledResolution scaledResolution) { - if (right < left) { + if(right < left) { int temp = right; right = left; left = temp; } - if (bottom < top) { + if(bottom < top) { int temp = bottom; bottom = top; top = temp; } - if (boundsStack.isEmpty()) { + if(boundsStack.isEmpty()) { boundsStack.push(new Bounds(left, top, right, bottom)); } else { boundsStack.push(boundsStack.peek().createSubBound(left, top, right, bottom)); } - if (!boundsStack.isEmpty()) { + if(!boundsStack.isEmpty()) { boundsStack.peek().set(scaledResolution); } GL11.glEnable(GL11.GL_SCISSOR_TEST); } public static void pop(ScaledResolution scaledResolution) { - if (!boundsStack.isEmpty()) { + if(!boundsStack.isEmpty()) { boundsStack.pop(); } - if (boundsStack.isEmpty()) { + if(boundsStack.isEmpty()) { GL11.glDisable(GL11.GL_SCISSOR_TEST); } else { boundsStack.peek().set(scaledResolution); @@ -83,4 +83,5 @@ public class GlScissorStack { boundsStack.clear(); GL11.glDisable(GL11.GL_SCISSOR_TEST); } + } diff --git a/src/main/java/com/thatgravyboat/skyblockhud/core/GuiElement.java b/src/main/java/com/thatgravyboat/skyblockhud/core/GuiElement.java index cb9b15a..ff817cf 100644 --- a/src/main/java/com/thatgravyboat/skyblockhud/core/GuiElement.java +++ b/src/main/java/com/thatgravyboat/skyblockhud/core/GuiElement.java @@ -1,10 +1,10 @@ package com.thatgravyboat.skyblockhud.core; -public abstract class GuiElement { +import net.minecraft.client.gui.Gui; - public abstract void render(); +public abstract class GuiElement extends Gui { + public abstract void render(); public abstract boolean mouseInput(int mouseX, int mouseY); - public abstract boolean keyboardInput(); } diff --git a/src/main/java/com/thatgravyboat/skyblockhud/core/GuiElementBoolean.java b/src/main/java/com/thatgravyboat/skyblockhud/core/GuiElementBoolean.java index 8daf4b1..7c401ed 100644 --- a/src/main/java/com/thatgravyboat/skyblockhud/core/GuiElementBoolean.java +++ b/src/main/java/com/thatgravyboat/skyblockhud/core/GuiElementBoolean.java @@ -37,7 +37,7 @@ public class GuiElementBoolean extends GuiElement { this.toggleCallback = toggleCallback; this.lastMillis = System.currentTimeMillis(); - if (value) animation = 36; + if(value) animation = 36; } @Override @@ -51,56 +51,58 @@ public class GuiElementBoolean extends GuiElement { long deltaMillis = currentMillis - lastMillis; lastMillis = currentMillis; boolean passedLimit = false; - if (previewValue != value) { - if ((previewValue && animation > 12) || (!previewValue && animation < 24)) { + if(previewValue != value) { + if((previewValue && animation > 12) || + (!previewValue && animation < 24)) { passedLimit = true; } } - if (previewValue != passedLimit) { - animation += deltaMillis / 10; + if(previewValue != passedLimit) { + animation += deltaMillis/10; } else { - animation -= deltaMillis / 10; + animation -= deltaMillis/10; } - lastMillis -= deltaMillis % 10; + lastMillis -= deltaMillis%10; - if (previewValue == value) { + if(previewValue == value) { animation = Math.max(0, Math.min(36, animation)); - } else if (!passedLimit) { - if (previewValue) { + } else if(!passedLimit) { + if(previewValue) { animation = Math.max(0, Math.min(12, animation)); } else { animation = Math.max(24, Math.min(36, animation)); } } else { - if (previewValue) { + if(previewValue) { animation = Math.max(12, animation); } else { animation = Math.min(24, animation); } } - int animation = (int) (LerpUtils.sigmoidZeroOne(this.animation / 36f) * 36); - if (animation < 3) { + int animation = (int)(LerpUtils.sigmoidZeroOne(this.animation/36f)*36); + if(animation < 3) { buttonLoc = GuiTextures.OFF; - } else if (animation < 13) { + } else if(animation < 13) { buttonLoc = GuiTextures.ONE; - } else if (animation < 23) { + } else if(animation < 23) { buttonLoc = GuiTextures.TWO; - } else if (animation < 33) { + } else if(animation < 33) { buttonLoc = GuiTextures.THREE; } Minecraft.getMinecraft().getTextureManager().bindTexture(buttonLoc); - RenderUtils.drawTexturedRect(x + animation, y, 12, 14); + RenderUtils.drawTexturedRect(x+animation, y, 12, 14); } @Override public boolean mouseInput(int mouseX, int mouseY) { - if (mouseX > x - clickRadius && mouseX < x + xSize + clickRadius && mouseY > y - clickRadius && mouseY < y + ySize + clickRadius) { - if (Mouse.getEventButton() == 0) { - if (Mouse.getEventButtonState()) { + if(mouseX > x-clickRadius && mouseX < x+xSize+clickRadius && + mouseY > y-clickRadius && mouseY < y+ySize+clickRadius) { + if(Mouse.getEventButton() == 0) { + if(Mouse.getEventButtonState()) { previewValue = !value; - } else if (previewValue == !value) { + } else if(previewValue == !value) { value = !value; toggleCallback.accept(value); } diff --git a/src/main/java/com/thatgravyboat/skyblockhud/core/GuiElementColour.java b/src/main/java/com/thatgravyboat/skyblockhud/core/GuiElementColour.java index 2092b31..e2d3e0a 100644 --- a/src/main/java/com/thatgravyboat/skyblockhud/core/GuiElementColour.java +++ b/src/main/java/com/thatgravyboat/skyblockhud/core/GuiElementColour.java @@ -18,10 +18,10 @@ import org.lwjgl.opengl.GL11; public class GuiElementColour extends GuiElement { - public static final ResourceLocation colour_selector_dot = new ResourceLocation("skyblockhud:core/colour_selector_dot.png"); - public static final ResourceLocation colour_selector_bar = new ResourceLocation("skyblockhud:core/colour_selector_bar.png"); - public static final ResourceLocation colour_selector_bar_alpha = new ResourceLocation("skyblockhud:core/colour_selector_bar_alpha.png"); - public static final ResourceLocation colour_selector_chroma = new ResourceLocation("skyblockhud:core/colour_selector_chroma.png"); + public static final ResourceLocation colour_selector_dot = new ResourceLocation("notenoughupdates:core/colour_selector_dot.png"); + public static final ResourceLocation colour_selector_bar = new ResourceLocation("notenoughupdates:core/colour_selector_bar.png"); + public static final ResourceLocation colour_selector_bar_alpha = new ResourceLocation("notenoughupdates:core/colour_selector_bar_alpha.png"); + public static final ResourceLocation colour_selector_chroma = new ResourceLocation("notenoughupdates:core/colour_selector_chroma.png"); private static final ResourceLocation colourPickerLocation = new ResourceLocation("mbcore:dynamic/colourpicker"); private static final ResourceLocation colourPickerBarValueLocation = new ResourceLocation("mbcore:dynamic/colourpickervalue"); @@ -30,8 +30,8 @@ public class GuiElementColour extends GuiElement { private int x; private int y; - private final int xSize = 119; - private final int ySize = 89; + private int xSize = 119; + private int ySize = 89; private float wheelAngle = 0; private float wheelRadius = 0; @@ -42,11 +42,20 @@ public class GuiElementColour extends GuiElement { private Runnable closeCallback; private String colour; - public GuiElementColour(int x, int y, String initialColour, Consumer<String> colourChangedCallback, Runnable closeCallback) { + private final boolean opacitySlider; + private final boolean valueSlider; + + public GuiElementColour(int x, int y, String initialColour, Consumer<String> colourChangedCallback, + Runnable closeCallback) { + this(x, y, initialColour, colourChangedCallback, closeCallback, true, true); + } + + public GuiElementColour(int x, int y, String initialColour, Consumer<String> colourChangedCallback, + Runnable closeCallback, boolean opacitySlider, boolean valueSlider) { final ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft()); - this.y = Math.max(10, Math.min(scaledResolution.getScaledHeight() - ySize - 10, y)); - this.x = Math.max(10, Math.min(scaledResolution.getScaledWidth() - xSize - 10, x)); + this.y = Math.max(10, Math.min(scaledResolution.getScaledHeight()-ySize-10, y)); + this.x = Math.max(10, Math.min(scaledResolution.getScaledWidth()-xSize-10, x)); this.colour = initialColour; this.colourChangedCallback = colourChangedCallback; @@ -56,11 +65,17 @@ public class GuiElementColour extends GuiElement { Color c = new Color(colour); float[] hsv = Color.RGBtoHSB(c.getRed(), c.getGreen(), c.getBlue(), null); updateAngleAndRadius(hsv); + + this.opacitySlider = opacitySlider; + this.valueSlider = valueSlider; + + if(!valueSlider) xSize -= 15; + if(!opacitySlider) xSize -= 15; } public void updateAngleAndRadius(float[] hsv) { this.wheelRadius = hsv[1]; - this.wheelAngle = hsv[0] * 360; + this.wheelAngle = hsv[0]*360; } public void render() { @@ -72,178 +87,219 @@ public class GuiElementColour extends GuiElement { BufferedImage bufferedImage = new BufferedImage(288, 288, BufferedImage.TYPE_INT_ARGB); float borderRadius = 0.05f; - if (Keyboard.isKeyDown(Keyboard.KEY_N)) borderRadius = 0; - for (int x = -16; x < 272; x++) { - for (int y = -16; y < 272; y++) { - float radius = (float) Math.sqrt(((x - 128) * (x - 128) + (y - 128) * (y - 128)) / 16384f); - float angle = (float) Math.toDegrees(Math.atan((128 - x) / (y - 128 + 1E-5)) + Math.PI / 2); - if (y < 128) angle += 180; - if (radius <= 1) { - int rgb = Color.getHSBColor(angle / 360f, (float) Math.pow(radius, 1.5f), hsv[2]).getRGB(); - bufferedImage.setRGB(x + 16, y + 16, rgb); - } else if (radius <= 1 + borderRadius) { - float invBlackAlpha = Math.abs(radius - 1 - borderRadius / 2) / borderRadius * 2; - float blackAlpha = 1 - invBlackAlpha; - - if (radius > 1 + borderRadius / 2) { - bufferedImage.setRGB(x + 16, y + 16, (int) (blackAlpha * 255) << 24); + if(Keyboard.isKeyDown(Keyboard.KEY_N)) borderRadius = 0; + for(int x=-16; x<272; x++) { + for(int y=-16; y<272; y++) { + float radius = (float) Math.sqrt(((x-128)*(x-128)+(y-128)*(y-128))/16384f); + float angle = (float) Math.toDegrees(Math.atan((128-x)/(y-128+1E-5))+Math.PI/2); + if(y < 128) angle += 180; + if(radius <= 1) { + int rgb = Color.getHSBColor(angle/360f, (float)Math.pow(radius, 1.5f), hsv[2]).getRGB(); + bufferedImage.setRGB(x+16, y+16, rgb); + } else if(radius <= 1+borderRadius) { + float invBlackAlpha = Math.abs(radius-1-borderRadius/2)/borderRadius*2; + float blackAlpha = 1-invBlackAlpha; + + if(radius > 1+borderRadius/2) { + bufferedImage.setRGB(x+16, y+16, (int)(blackAlpha*255) << 24); } else { - Color col = Color.getHSBColor(angle / 360f, 1, hsv[2]); - int rgb = (int) (col.getRed() * invBlackAlpha) << 16 | (int) (col.getGreen() * invBlackAlpha) << 8 | (int) (col.getBlue() * invBlackA |
