aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/cc/polyfrost/oneconfig/lwjgl
diff options
context:
space:
mode:
authorWyvest <45589059+Wyvest@users.noreply.github.com>2022-05-27 21:31:59 +0700
committerWyvest <45589059+Wyvest@users.noreply.github.com>2022-05-27 21:31:59 +0700
commitab2dd02145d5f89455a74605dd953888761d0ddb (patch)
treed8a9e909798a9bf84e876319c1fdea758d9c5963 /src/main/java/cc/polyfrost/oneconfig/lwjgl
parent2de9cec78992b9589c13ca24b911a1d8ce381c75 (diff)
downloadOneConfig-ab2dd02145d5f89455a74605dd953888761d0ddb.tar.gz
OneConfig-ab2dd02145d5f89455a74605dd953888761d0ddb.tar.bz2
OneConfig-ab2dd02145d5f89455a74605dd953888761d0ddb.zip
javadoc a lot of stuff + reorganize
Diffstat (limited to 'src/main/java/cc/polyfrost/oneconfig/lwjgl')
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/lwjgl/RenderManager.java258
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/lwjgl/image/ImageLoader.java82
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/lwjgl/image/Images.java6
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/lwjgl/image/SVGs.java6
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/lwjgl/scissor/Scissor.java5
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/lwjgl/scissor/ScissorManager.java21
6 files changed, 365 insertions, 13 deletions
diff --git a/src/main/java/cc/polyfrost/oneconfig/lwjgl/RenderManager.java b/src/main/java/cc/polyfrost/oneconfig/lwjgl/RenderManager.java
index 8d68715..f14390e 100644
--- a/src/main/java/cc/polyfrost/oneconfig/lwjgl/RenderManager.java
+++ b/src/main/java/cc/polyfrost/oneconfig/lwjgl/RenderManager.java
@@ -3,14 +3,14 @@ package cc.polyfrost.oneconfig.lwjgl;
import cc.polyfrost.oneconfig.config.OneConfigConfig;
import cc.polyfrost.oneconfig.config.data.InfoType;
import cc.polyfrost.oneconfig.gui.OneConfigGui;
+import cc.polyfrost.oneconfig.libs.universal.UGraphics;
+import cc.polyfrost.oneconfig.libs.universal.UMinecraft;
+import cc.polyfrost.oneconfig.libs.universal.UResolution;
import cc.polyfrost.oneconfig.lwjgl.font.FontManager;
import cc.polyfrost.oneconfig.lwjgl.font.Fonts;
import cc.polyfrost.oneconfig.lwjgl.image.ImageLoader;
import cc.polyfrost.oneconfig.lwjgl.image.Images;
import cc.polyfrost.oneconfig.lwjgl.image.SVGs;
-import cc.polyfrost.oneconfig.libs.universal.UGraphics;
-import cc.polyfrost.oneconfig.libs.universal.UMinecraft;
-import cc.polyfrost.oneconfig.libs.universal.UResolution;
import cc.polyfrost.oneconfig.utils.InputUtils;
import cc.polyfrost.oneconfig.utils.NetworkUtils;
import net.minecraft.client.gui.Gui;
@@ -24,6 +24,9 @@ import static org.lwjgl.nanovg.NanoVG.*;
import static org.lwjgl.nanovg.NanoVGGL2.NVG_ANTIALIAS;
import static org.lwjgl.nanovg.NanoVGGL2.nvgCreate;
+/**
+ * Handles NanoVG rendering and wraps it in a more convenient interface.
+ */
public final class RenderManager {
private RenderManager() {
@@ -33,10 +36,22 @@ public final class RenderManager {
private static long vg = -1;
+ /**
+ * Sets up rendering, calls the consumer with the NanoVG context, and then cleans up.
+ *
+ * @see RenderManager#setupAndDraw(boolean, LongConsumer)
+ * @param consumer The consumer to call.
+ */
public static void setupAndDraw(LongConsumer consumer) {
setupAndDraw(false, consumer);
}
+ /**
+ * Sets up rendering, calls the consumer with the NanoVG context, and then cleans up.
+ *
+ * @param mcScaling Whether to render with Minecraft's scaling.
+ * @param consumer The consumer to call.
+ */
public static void setupAndDraw(boolean mcScaling, LongConsumer consumer) {
if (vg == -1) {
vg = nvgCreate(NVG_ANTIALIAS);
@@ -67,6 +82,16 @@ public final class RenderManager {
GL11.glPopAttrib();
}
+ /**
+ * Draws a rectangle with the given parameters.
+ *
+ * @param vg The NanoVG context.
+ * @param x The x position.
+ * @param y The y position.
+ * @param width The width.
+ * @param height The height.
+ * @param color The color.
+ */
public static void drawRectangle(long vg, float x, float y, float width, float height, int color) { // TODO make everything use this one day
if (OneConfigConfig.ROUNDED_CORNERS) {
drawRoundedRect(vg, x, y, width, height, color, OneConfigConfig.CORNER_RADIUS);
@@ -75,6 +100,18 @@ public final class RenderManager {
}
}
+ /**
+ * Draws a rounded gradient rectangle with the given parameters.
+ *
+ * @param vg The NanoVG context.
+ * @param x The x position.
+ * @param y The y position.
+ * @param width The width.
+ * @param height The height.
+ * @param color The first color of the gradient.
+ * @param color2 The second color of the gradient.
+ * @param radius The corner radius.
+ */
public static void drawGradientRoundedRect(long vg, float x, float y, float width, float height, int color, int color2, float radius) {
NVGPaint bg = NVGPaint.create();
nvgBeginPath(vg);
@@ -87,6 +124,7 @@ public final class RenderManager {
nvgColor2.free();
}
+ //todo wtf does this do - wyvest, 2022
public static void drawHSBBox(long vg, float x, float y, float width, float height, int colorTarget) {
drawRoundedRect(vg, x, y, width, height, colorTarget, 8f);
@@ -111,6 +149,17 @@ public final class RenderManager {
nvgColor4.free();
}
+ /**
+ * Draws a gradient rectangle with the given parameters.
+ *
+ * @param vg The NanoVG context.
+ * @param x The x position.
+ * @param y The y position.
+ * @param width The width.
+ * @param height The height.
+ * @param color The first color of the gradient.
+ * @param color2 The second color of the gradient.
+ */
public static void drawGradientRect(long vg, float x, float y, float width, float height, int color, int color2) {
NVGPaint bg = NVGPaint.create();
nvgBeginPath(vg);
@@ -124,6 +173,16 @@ public final class RenderManager {
nvgColor2.free();
}
+ /**
+ * Draws a rectangle with the given parameters.
+ *
+ * @param vg The NanoVG context.
+ * @param x The x position.
+ * @param y The y position.
+ * @param width The width.
+ * @param height The height.
+ * @param color The color.
+ */
public static void drawRect(long vg, float x, float y, float width, float height, int color) {
nvgBeginPath(vg);
nvgRect(vg, x, y, width, height);
@@ -132,6 +191,17 @@ public final class RenderManager {
nvgColor.free();
}
+ /**
+ * Draws a rounded rectangle with the given parameters.
+ *
+ * @param vg The NanoVG context.
+ * @param x The x position.
+ * @param y The y position.
+ * @param width The width.
+ * @param height The height.
+ * @param color The color.
+ * @param radius The radius.
+ */
public static void drawRoundedRect(long vg, float x, float y, float width, float height, int color, float radius) {
nvgBeginPath(vg);
nvgRoundedRect(vg, x, y, width, height, radius);
@@ -141,6 +211,7 @@ public final class RenderManager {
nvgColor.free();
}
+ //todo wtf does this do - wyvest, 2022
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);
@@ -150,6 +221,18 @@ public final class RenderManager {
nvgColor.free();
}
+ /**
+ * Draws a hollow rounded rectangle with the given parameters.
+ *
+ * @param vg The NanoVG context.
+ * @param x The x position.
+ * @param y The y position.
+ * @param width The width.
+ * @param height The height.
+ * @param color The color.
+ * @param radius The radius.
+ * @param thickness The thickness.
+ */
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);
@@ -162,6 +245,14 @@ public final class RenderManager {
nvgColor.free();
}
+ /**
+ * Draws a circle with the given parameters.
+ * @param vg The NanoVG context.
+ * @param x The x position.
+ * @param y The y position.
+ * @param radius The radius.
+ * @param color The color.
+ */
public static void drawCircle(long vg, float x, float y, float radius, int color) {
nvgBeginPath(vg);
nvgCircle(vg, x, y, radius);
@@ -170,6 +261,18 @@ public final class RenderManager {
nvgColor.free();
}
+ /**
+ * Draws a String with the given parameters.
+ * @param vg The NanoVG context.
+ * @param text The text.
+ * @param x The x position.
+ * @param y The y position.
+ * @param color The color.
+ * @param size The size.
+ * @param font The font.
+ *
+ * @see cc.polyfrost.oneconfig.lwjgl.font.Font
+ */
public static void drawString(long vg, String text, float x, float y, int color, float size, Fonts font) {
nvgBeginPath(vg);
nvgFontSize(vg, size);
@@ -181,6 +284,7 @@ public final class RenderManager {
nvgColor.free();
}
+ //todo wtf does this do - wyvest, 2022
public static void drawString(long vg, String text, float x, float y, int color, float size, int lineHeight, Fonts font) {
nvgBeginPath(vg);
nvgFontSize(vg, size);
@@ -193,16 +297,34 @@ public final class RenderManager {
nvgColor.free();
}
- /** Draw a formatted URL (a string in blue with an underline) that when clicked, opens the given text. */
+ /**
+ * Draw a formatted URL (a string in blue with an underline) that when clicked, opens the given text.
+ *
+ * <p><b>This does NOT scale to Minecraft's GUI scale!</b></p>
+ *
+ * @see RenderManager#drawString(long, String, float, float, int, float, Fonts)
+ * @see InputUtils#isAreaClicked(int, int, int, int)
+ */
public static void drawURL(long vg, String url, float x, float y, float size, Fonts font) {
drawString(vg, url, x, y, OneConfigConfig.PRIMARY_500, size, font);
float length = getTextWidth(vg, url, size, font);
drawRectangle(vg, x, y + size / 2, length, 1, OneConfigConfig.PRIMARY_500);
- if(InputUtils.isAreaClicked((int) (x - 2), (int) (y - 1), (int) (length + 4), (int) (size / 2 + 3))) {
+ if (InputUtils.isAreaClicked((int) (x - 2), (int) (y - 1), (int) (length + 4), (int) (size / 2 + 3))) {
NetworkUtils.browseLink(url);
}
}
+ /**
+ * Draws a String wrapped at the given width, with the given parameters.
+ * @param vg The NanoVG context.
+ * @param text The text.
+ * @param x The x position.
+ * @param y The y position.
+ * @param width The width.
+ * @param color The color.
+ * @param size The size.
+ * @param font The font.
+ */
public static void drawWrappedString(long vg, String text, float x, float y, float width, int color, float size, Fonts font) {
nvgBeginPath(vg);
nvgFontSize(vg, size);
@@ -214,6 +336,17 @@ public final class RenderManager {
nvgColor.free();
}
+ /**
+ * Draws an image with the provided file path.
+ * @param vg The NanoVG context.
+ * @param filePath The file path.
+ * @param x The x position.
+ * @param y The y position.
+ * @param width The width.
+ * @param height The height.
+ *
+ * @see RenderManager#drawImage(long, String, float, float, float, float, int)
+ */
public static void drawImage(long vg, String filePath, float x, float y, float width, float height) {
if (ImageLoader.INSTANCE.loadImage(vg, filePath)) {
NVGPaint imagePaint = NVGPaint.calloc();
@@ -227,6 +360,16 @@ public final class RenderManager {
}
}
+ /**
+ * Draws an image with the provided file path.
+ * @param vg The NanoVG context.
+ * @param filePath The file path.
+ * @param x The x position.
+ * @param y The y position.
+ * @param width The width.
+ * @param height The height.
+ * @param color The color.
+ */
public static void drawImage(long vg, String filePath, float x, float y, float width, float height, int color) {
if (ImageLoader.INSTANCE.loadImage(vg, filePath)) {
NVGPaint imagePaint = NVGPaint.calloc();
@@ -241,6 +384,16 @@ public final class RenderManager {
}
}
+ /**
+ * Draws a rounded image with the provided file path and parameters.
+ * @param vg The NanoVG context.
+ * @param filePath The file path.
+ * @param x The x position.
+ * @param y The y position.
+ * @param width The width.
+ * @param height The height.
+ * @param radius The radius.
+ */
public static void drawRoundImage(long vg, String filePath, float x, float y, float width, float height, float radius) {
if (ImageLoader.INSTANCE.loadImage(vg, filePath)) {
NVGPaint imagePaint = NVGPaint.calloc();
@@ -254,19 +407,41 @@ public final class RenderManager {
}
}
+ /**
+ * Draws a rounded image with the provided file path and parameters.
+ *
+ * @see RenderManager#drawRoundImage(long, String, float, float, float, float, float)
+ */
public static void drawRoundImage(long vg, Images filePath, float x, float y, float width, float height, float radius) {
drawRoundImage(vg, filePath.filePath, x, y, width, height, radius);
}
+ /**
+ * Draws an image with the provided file path and parameters.
+ *
+ * @see RenderManager#drawImage(long, String, float, float, float, float)
+ */
public static void drawImage(long vg, Images filePath, float x, float y, float width, float height) {
drawImage(vg, filePath.filePath, x, y, width, height);
}
+ /**
+ * Draws an image with the provided file path and parameters.
+ *
+ * @see RenderManager#drawImage(long, String, float, float, float, float, int)
+ */
public static void drawImage(long vg, Images filePath, float x, float y, float width, float height, int color) {
drawImage(vg, filePath.filePath, x, y, width, height, color);
}
-
+ /**
+ * Get the width of the provided String.
+ * @param vg The NanoVG context.
+ * @param text The text.
+ * @param fontSize The font size.
+ * @param font The font.
+ * @return The width of the text.
+ */
public static float getTextWidth(long vg, String text, float fontSize, Fonts font) {
float[] bounds = new float[4];
nvgFontSize(vg, fontSize);
@@ -274,6 +449,16 @@ public final class RenderManager {
return nvgTextBounds(vg, 0, 0, text, bounds);
}
+ /**
+ * Draws a line with the provided parameters.
+ * @param vg The NanoVG context.
+ * @param x The x position.
+ * @param y The y position.
+ * @param endX The end x position.
+ * @param endY The end y position.
+ * @param width The width.
+ * @param color The color.
+ */
public static void drawLine(long vg, float x, float y, float endX, float endY, float width, int color) {
nvgBeginPath(vg);
nvgMoveTo(vg, x, y);
@@ -285,6 +470,7 @@ public final class RenderManager {
nvgColor.free();
}
+ //todo i know what this does but diamond knows what it does in detail so diamond needs to javadoc this
public static void drawDropShadow(long vg, float x, float y, float w, float h, float blur, float spread, float cornerRadius) {
try (
NVGPaint shadowPaint = NVGPaint.calloc(); // allocating memory to pass color to nanovg wrapper
@@ -320,6 +506,14 @@ public final class RenderManager {
}
}
+ /**
+ * Fills the provided {@link NVGColor} with the provided RGBA values.
+ * @param r The red value.
+ * @param g The green value.
+ * @param b The blue value.
+ * @param a The alpha value.
+ * @param color The {@link NVGColor} to fill.
+ */
public static void fillNvgColorWithRGBA(float r, float g, float b, float a, NVGColor color) {
color.r(r);
color.g(g);
@@ -327,7 +521,13 @@ public final class RenderManager {
color.a(a);
}
-
+ /**
+ * Create a {@link NVGColor} from the provided RGBA values.
+ *
+ * @param vg The NanoVG context.
+ * @param color The color.
+ * @return The {@link NVGColor} created.
+ */
public static NVGColor color(long vg, int color) {
NVGColor nvgColor = NVGColor.calloc();
nvgRGBA((byte) (color >> 16 & 0xFF), (byte) (color >> 8 & 0xFF), (byte) (color & 0xFF), (byte) (color >> 24 & 0xFF), nvgColor);
@@ -335,14 +535,36 @@ public final class RenderManager {
return nvgColor;
}
+ /**
+ * Scales all rendering by the provided scale.
+ * @param vg The NanoVG context.
+ * @param x The x scale.
+ * @param y The y scale.
+ */
public static void scale(long vg, float x, float y) {
nvgScale(vg, x, y);
}
+ /**
+ * Sets the global alpha value to render with.
+ *
+ * @param vg The NanoVG context.
+ * @param alpha The alpha value.
+ */
public static void setAlpha(long vg, float alpha) {
nvgGlobalAlpha(vg, alpha);
}
+ /**
+ * Draws a SVG with the provided file path and parameters.
+ *
+ * @param vg The NanoVG context.
+ * @param filePath The file path.
+ * @param x The x position.
+ * @param y The y position.
+ * @param width The width.
+ * @param height The height.
+ */
public static void drawSvg(long vg, String filePath, float x, float y, float width, float height) {
float w = width;
float h = height;
@@ -362,6 +584,17 @@ public final class RenderManager {
}
}
+ /**
+ * Draws a SVG with the provided file path and parameters.
+ *
+ * @param vg The NanoVG context.
+ * @param filePath The file path.
+ * @param x The x position.
+ * @param y The y position.
+ * @param width The width.
+ * @param height The height.
+ * @param color The color.
+ */
public static void drawSvg(long vg, String filePath, float x, float y, float width, float height, int color) {
float w = width;
float h = height;
@@ -382,14 +615,25 @@ public final class RenderManager {
}
}
+ /**
+ * Draws an SVG with the provided file path and parameters.
+ *
+ * @see RenderManager#drawSvg(long, String, float, float, float, float)
+ */
public static void drawSvg(long vg, SVGs svg, float x, float y, float width, float height) {
drawSvg(vg, svg.filePath, x, y, width, height);
}
+ /**
+ * Draws an SVG with the provided file path and parameters.
+ *
+ * @see RenderManager#drawSvg(long, String, float, float, float, float, int)
+ */
public static void drawSvg(long vg, SVGs svg, float x, float y, float width, float height, int color) {
drawSvg(vg, svg.filePath, x, y, width, height, color);
}
+ //todo diamond come here and write javadocs please
public static void drawInfo(long vg, InfoType type, float x, float y, float size) {
SVGs icon = null;
int colorOuter = 0;
diff --git a/src/main/java/cc/polyfrost/oneconfig/lwjgl/image/ImageLoader.java b/src/main/java/cc/polyfrost/oneconfig/lwjgl/image/ImageLoader.java
index fb436dd..289ab03 100644
--- a/src/main/java/cc/polyfrost/oneconfig/lwjgl/image/ImageLoader.java
+++ b/src/main/java/cc/polyfrost/oneconfig/lwjgl/image/ImageLoader.java
@@ -13,11 +13,27 @@ import java.io.InputStreamReader;
import java.nio.ByteBuffer;
import java.util.HashMap;
-public class ImageLoader {
+/**
+ * Loads images and SVGs from resources into NanoVG.
+ *
+ * @see cc.polyfrost.oneconfig.lwjgl.RenderManager
+ * @see Images
+ * @see SVGs
+ */
+public final class ImageLoader {
+ private ImageLoader() {
+
+ }
private final HashMap<String, Integer> imageHashMap = new HashMap<>();
private final HashMap<String, Integer> svgHashMap = new HashMap<>();
public static ImageLoader INSTANCE = new ImageLoader();
+ /**
+ * Loads an image from resources.
+ * @param vg The NanoVG context.
+ * @param fileName The name of the file to load.
+ * @return Whether the image was loaded successfully.
+ */
public boolean loadImage(long vg, String fileName) {
if (!imageHashMap.containsKey(fileName)) {
int[] width = {0};
@@ -40,8 +56,16 @@ public class ImageLoader {
return true;
}
- public boolean loadSVG(long vg, String fileName, float SVGWidth, float SVGHeight) {
- String name = fileName + "-" + SVGWidth + "-" + SVGHeight;
+ /**
+ * Loads an SVG from resources.
+ * @param vg The NanoVG context.
+ * @param fileName The name of the file to load.
+ * @param width The width of the SVG.
+ * @param height The height of the SVG.
+ * @return Whether the SVG was loaded successfully.
+ */
+ public boolean loadSVG(long vg, String fileName, float width, float height) {
+ String name = fileName + "-" + width + "-" + height;
if (!svgHashMap.containsKey(name)) {
try {
InputStream inputStream = this.getClass().getResourceAsStream(fileName);
@@ -60,7 +84,7 @@ public class ImageLoader {
int w = (int) svg.width();
int h = (int) svg.height();
- float scale = Math.max(SVGWidth / w, SVGHeight / h);
+ float scale = Math.max(width / w, height / h);
w = (int) (w * scale);
h = (int) (h * scale);
@@ -81,34 +105,80 @@ public class ImageLoader {
return true;
}
+ /**
+ * Get a loaded image from the cache.
+ * <p><b>Requires the image to have been loaded first.</b></p>
+ *
+ * @param fileName The name of the file to load.
+ * @return The image
+ * @see ImageLoader#loadImage(long, String)
+ */
public int getImage(String fileName) {
return imageHashMap.get(fileName);
}
+ /**
+ * Remove an image from the cache, allowing the image to be garbage collected.
+ * Should be used when the GUI rendering the image is closed.
+ *
+ * @param vg The NanoVG context.
+ * @param fileName The name of the file to remove.
+ *
+ * @see ImageLoader#loadImage(long, String)
+ */
public void removeImage(long vg, String fileName) {
NanoVG.nvgDeleteImage(vg, imageHashMap.get(fileName));
imageHashMap.remove(fileName);
}
+ /**
+ * Clears all images from the cache, allowing the images cleared to be garbage collected.
+ * Should be used when the GUI rendering loaded images are closed.
+ *
+ * @param vg The NanoVG context.
+ */
public void clearImages(long vg) {
HashMap<String, Integer> temp = new HashMap<>(imageHashMap);
for (String image : temp.keySet()) {
NanoVG.nvgDeleteImage(vg, imageHashMap.get(image));
imageHashMap.remove(image);
}
- }
+ }
- public int getSVG( String fileName, float width, float height) {
+ /**
+ * Get a loaded SVG from the cache.
+ * <p><b>Requires the SVG to have been loaded first.</b></p>
+ *
+ * @param fileName The name of the file to load.
+ * @return The SVG
+ * @see ImageLoader#loadSVG(long, String, float, float)
+ */
+ public int getSVG(String fileName, float width, float height) {
String name = fileName + "-" + width + "-" + height;
return svgHashMap.get(name);
}
+ /**
+ * Remove a SVG from the cache, allowing the SVG to be garbage collected.
+ * Should be used when the GUI rendering the SVG is closed.
+ *
+ * @param vg The NanoVG context.
+ * @param fileName The name of the file to remove.
+ *
+ * @see ImageLoader#loadSVG(long, String, float, float)
+ */
public void removeSVG(long vg, String fileName, float width, float height) {
String name = fileName + "-" + width + "-" + height;
NanoVG.nvgDeleteImage(vg, imageHashMap.get(name));
svgHashMap.remove(name);
}
+ /**
+ * Clears all SVGs from the cache, allowing the SVGs cleared to be garbage collected.
+ * Should be used when the GUI rendering loaded SVGs are closed.
+ *
+ * @param vg The NanoVG context.
+ */
public void clearSVGs(long vg) {
HashMap<String, Integer> temp = new HashMap<>(svgHashMap);
for (String image : temp.keySet()) {
diff --git a/src/main/java/cc/polyfrost/oneconfig/lwjgl/image/Images.java b/src/main/java/cc/polyfrost/oneconfig/lwjgl/image/Images.java
index c42e581..af62b00 100644
--- a/src/main/java/cc/polyfrost/oneconfig/lwjgl/image/Images.java
+++ b/src/main/java/cc/polyfrost/oneconfig/lwjgl/image/Images.java
@@ -1,5 +1,11 @@
package cc.polyfrost.oneconfig.lwjgl.image;
+/**
+ * An enum of images used in OneConfig.
+ *
+ * @see cc.polyfrost.oneconfig.lwjgl.RenderManager#drawImage(long, String, float, float, float, float, int)
+ * @see ImageLoader
+ */
public enum Images {
HUE_GRADIENT("/assets/oneconfig/colorui/huegradient.png"),
COLOR_WHEEL("/assets/oneconfig/colorui/colorwheel.png"),
diff --git a/src/main/java/cc/polyfrost/oneconfig/lwjgl/image/SVGs.java b/src/main/java/cc/polyfrost/oneconfig/lwjgl/image/SVGs.java
index 1b8744f..76c93a4 100644
--- a/src/main/java/cc/polyfrost/oneconfig/lwjgl/image/SVGs.java
+++ b/src/main/java/cc/polyfrost/oneconfig/lwjgl/image/SVGs.java
@@ -1,5 +1,11 @@
package cc.polyfrost.oneconfig.lwjgl.image;
+/**
+ * An enum of SVGs used in OneConfig.
+ *
+ * @see cc.polyfrost.oneconfig.lwjgl.RenderManager#drawSvg(long, String, float, float, float, float, int)
+ * @see ImageLoader
+ */
public enum SVGs {
ALIGN_H_CENTER("/assets/oneconfig/icons/AlignHCenter.svg"),
ALIGN_H_LEFT("/assets/oneconfig/icons/AlignHLeft.svg"),
diff --git a/src/main/java/cc/polyfrost/oneconfig/lwjgl/scissor/Scissor.java b/src/main/java/cc/polyfrost/oneconfig/lwjgl/scissor/Scissor.java
index 9523865..089268f 100644
--- a/src/main/java/cc/polyfrost/oneconfig/lwjgl/scissor/Scissor.java
+++ b/src/main/java/cc/polyfrost/oneconfig/lwjgl/scissor/Scissor.java
@@ -1,5 +1,10 @@
package cc.polyfrost.oneconfig.lwjgl.scissor;
+/**
+ * A class that represents a scissor rectangle.
+ *
+ * @see ScissorManager
+ */
public class Scissor {
public float x;
public float y;
diff --git a/src/main/java/cc/polyfrost/oneconfig/lwjgl/scissor/ScissorManager.java b/src/main/java/cc/polyfrost/oneconfig/lwjgl/scissor/ScissorManager.java
index 1697b7e..05747df 100644
--- a/src/main/java/cc/polyfrost/oneconfig/lwjgl/scissor/ScissorManager.java
+++ b/src/main/java/cc/polyfrost/oneconfig/lwjgl/scissor/ScissorManager.java
@@ -4,9 +4,21 @@ import org.lwjgl.nanovg.NanoVG;
import java.util.ArrayList;
+/**
+ * Provides an easy way to manage and group scissor rectangles.
+ */
public class ScissorManager {
private static final ArrayList<Scissor> scissors = new ArrayList<>();
+ /**
+ * Adds and applies a scissor rectangle to the list of scissor rectangles.
+ * @param vg The NanoVG context.
+ * @param x The x coordinate of the scissor rectangle.
+ * @param y The y coordinate of the scissor rectangle.
+ * @param width The width of the scissor rectangle.
+ * @param height The height of the scissor rectangle.
+ * @return The scissor rectangle.
+ */
public static Scissor scissor(long vg, float x, float y, float width, float height) {
Scissor scissor = new Scissor(x, y, width, height);
if (scissors.contains(scissor)) return scissor;
@@ -15,6 +27,11 @@ public class ScissorManager {
return scissor;
}
+ /**
+ * Resets the scissor rectangle provided.
+ * @param vg The NanoVG context.
+ * @param scissor The scissor rectangle to reset.
+ */
public static void resetScissor(long vg, Scissor scissor) {
if (scissors.contains(scissor)) {
scissors.remove(scissor);
@@ -22,6 +39,10 @@ public class ScissorManager {
}
}
+ /**
+ * Clear all scissor rectangles.
+ * @param vg The NanoVG context.
+ */
public static void clearScissors(long vg) {
scissors.clear();
NanoVG.nvgResetScissor(vg);