package wtf.opal.utility.render;

import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.client.gui.DrawContext;

@Environment(EnvType.CLIENT)
public final class LayoutHelper {
   public static float percentWidth(DrawContext ctx, float percent) {
      return (float)ctx.getScaledWindowWidth() * percent;
   }

   public static float percentHeight(DrawContext ctx, float percent) {
      return (float)ctx.getScaledWindowHeight() * percent;
   }

   public static float centerX(DrawContext ctx, float elementWidth) {
      return (float)ctx.getScaledWindowWidth() / 2.0F - elementWidth / 2.0F;
   }

   public static float centerY(DrawContext ctx, float elementHeight) {
      return (float)ctx.getScaledWindowHeight() / 2.0F - elementHeight / 2.0F;
   }
}
