package io.polyfrost.oneconfig.renderer; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.FontRenderer; import net.minecraft.client.gui.Gui; import net.minecraft.client.renderer.GlStateManager; import net.minecraft.util.ResourceLocation; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import java.awt.*; public class Renderer extends Gui { public static final Logger renderLog = LogManager.getLogger("OneConfig Renderer"); private static final Minecraft mc = Minecraft.getMinecraft(); private static final FontRenderer fr = mc.fontRendererObj; public static void drawRectangle(int left, int top, int right, int bottom, int color) { Gui.drawRect(left, top, right, bottom, color); } public static void drawTextScale(String text, float x, float y, int color, boolean shadow, float scale) { GlStateManager.pushMatrix(); GlStateManager.scale(scale, scale, 1); mc.fontRendererObj.drawString(text, x * (1 / scale), y * (1 / scale), color, shadow); GlStateManager.popMatrix(); } public static void drawScaledImage(ResourceLocation location, int x, int y, int targetX, int targetY) { GlStateManager.enableBlend(); GlStateManager.color(1f, 1f, 1f, 1f); mc.getTextureManager().bindTexture(location); Gui.drawScaledCustomSizeModalRect(x, y, 0, 0, targetX, targetY, targetX, targetY, targetX, targetY); } public static void drawRoundRectangle(int left, int top, int right, int bottom, int cornerRadius, int color) { } public static float clamp(float number) { return number < (float) 0.0 ? (float) 0.0 : Math.min(number, (float) 1.0); } public static float easeOut(float current, float goal) { if (Math.floor(Math.abs(goal - current) / (float) 0.01) > 0) { return current + (goal - current) / (float) 20.0; } else { return goal; } } public static Color getColorFromInt(int color) { float f = (float)(color >> 16 & 255) / 255.0F; float f1 = (float)(color >> 8 & 255) / 255.0F; float f2 = (float)(color & 255) / 255.0F; float f3 = (float)(color >> 24 & 255) / 255.0F; return new Color(f, f1, f2, f3); } }