diff options
author | DeDiamondPro <67508414+DeDiamondPro@users.noreply.github.com> | 2022-04-24 14:46:10 +0200 |
---|---|---|
committer | DeDiamondPro <67508414+DeDiamondPro@users.noreply.github.com> | 2022-04-24 14:46:10 +0200 |
commit | 087267b1e9a0562ca80604d583fc6c0790e0f733 (patch) | |
tree | 53019267804181b9e8ff42d90783d04c3119efa5 /src/main/java/io/polyfrost/oneconfig/lwjgl | |
parent | 9a3d070d80d569bea3f1b6b162bb061a7d9446db (diff) | |
parent | 5417c7bd2d43c306863707bb91e7c88a651a696b (diff) | |
download | OneConfig-087267b1e9a0562ca80604d583fc6c0790e0f733.tar.gz OneConfig-087267b1e9a0562ca80604d583fc6c0790e0f733.tar.bz2 OneConfig-087267b1e9a0562ca80604d583fc6c0790e0f733.zip |
Merge branch 'master' of github.com:Polyfrost/OneConfig
merge or smthing
Diffstat (limited to 'src/main/java/io/polyfrost/oneconfig/lwjgl')
-rw-r--r-- | src/main/java/io/polyfrost/oneconfig/lwjgl/RenderManager.java | 27 | ||||
-rw-r--r-- | src/main/java/io/polyfrost/oneconfig/lwjgl/image/ImageLoader.java | 12 |
2 files changed, 26 insertions, 13 deletions
diff --git a/src/main/java/io/polyfrost/oneconfig/lwjgl/RenderManager.java b/src/main/java/io/polyfrost/oneconfig/lwjgl/RenderManager.java index fa4b6bc..066218a 100644 --- a/src/main/java/io/polyfrost/oneconfig/lwjgl/RenderManager.java +++ b/src/main/java/io/polyfrost/oneconfig/lwjgl/RenderManager.java @@ -124,6 +124,15 @@ public final class RenderManager { nvgColor.free(); } + public static void drawRoundedRectVaried(long vg, float x, float y, float width, float height, int color, float radiusTL, float radiusTR, float radiusBR, float radiusBL) { + nvgBeginPath(vg); + nvgRoundedRectVarying(vg, x, y, width, height, radiusTL, radiusTR, radiusBR, radiusBL); + color(vg, color); + NVGColor nvgColor = color(vg, color); + nvgFill(vg); + nvgColor.free(); + } + public static void drawHollowRoundRect(long vg, float x, float y, float width, float height, int color, float radius, float thickness) { nvgBeginPath(vg); nvgRoundedRect(vg, x + thickness, y + thickness, width - thickness, height - thickness, radius); @@ -192,9 +201,9 @@ public final class RenderManager { NSVGPath path; int i; for (shape = image.shapes(); shape != null; shape.next()) { - //if ((shape.flags() == NSVG_FLAGS_VISIBLE)) { - // continue; - //} + if ((shape.flags() == NSVG_FLAGS_VISIBLE)) { + continue; + } nvgFillColor(vg, color(vg, shape.fill().color())); nvgStrokeColor(vg, color(vg, shape.stroke().color())); @@ -204,21 +213,15 @@ public final class RenderManager { nvgBeginPath(vg); FloatBuffer points = path.pts(); nvgMoveTo(vg, points.get(0), points.get(1)); - for (i = 0; i < path.npts() - 1; i += 3) { - float[] p = new float[10]; - for (int j = 0; j < i * 2 + 3; j++) { // THIS WONT WORK WHy why why why - p[j] = points.get(j); - System.out.println(j + " " + p[j]); - } - nvgBezierTo(vg, p[2], p[3], p[4], p[5], p[6], p[7]); + for (i = 1; i < path.npts() - 1; i += 3) { + int b = i * 2; + nvgBezierTo(vg, points.get(b), points.get(b + 1), points.get(b + 2), points.get(b + 3), points.get(b + 4), points.get(b + 5)); } if (path.closed() == 1) { nvgLineTo(vg, points.get(0), points.get(1)); } nvgStroke(vg); } - - } } catch (Exception e) { //e.printStackTrace(); diff --git a/src/main/java/io/polyfrost/oneconfig/lwjgl/image/ImageLoader.java b/src/main/java/io/polyfrost/oneconfig/lwjgl/image/ImageLoader.java index 6fbd27f..4a35959 100644 --- a/src/main/java/io/polyfrost/oneconfig/lwjgl/image/ImageLoader.java +++ b/src/main/java/io/polyfrost/oneconfig/lwjgl/image/ImageLoader.java @@ -10,6 +10,7 @@ import org.lwjgl.stb.STBImage; import org.lwjgl.system.MemoryStack; import java.io.BufferedReader; +import java.io.InputStream; import java.io.InputStreamReader; import java.nio.ByteBuffer; import java.nio.CharBuffer; @@ -46,7 +47,16 @@ public class ImageLoader { public boolean loadSVGImage(String fileName) { if(!NSVGImageHashMap.containsKey(fileName)) { try { - CharSequence s = new BufferedReader(new InputStreamReader(Minecraft.getMinecraft().getResourceManager().getResource(new ResourceLocation("oneconfig", fileName)).getInputStream())).readLine(); + InputStream inputStream = Minecraft.getMinecraft().getResourceManager().getResource(new ResourceLocation("oneconfig", fileName)).getInputStream(); + StringBuilder resultStringBuilder = new StringBuilder(); + try (BufferedReader br + = new BufferedReader(new InputStreamReader(inputStream))) { + String line; + while ((line = br.readLine()) != null) { + resultStringBuilder.append(line); + } + } + CharSequence s = resultStringBuilder.toString(); System.out.println(s); NSVGImage image = NanoSVG.nsvgParse(s, "px", 96f); NSVGImageHashMap.put(fileName, image); |