package se.urmo.game.util;

import java.awt.*;
import java.awt.image.BufferedImage;

public class MiscUtil {
    public static BufferedImage createOutlinedBox(int width, int height, Color outlineColor, float lineThickness) {
        BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);
        Graphics2D g2d = image.createGraphics();

        // Optional: Disable anti-aliasing for pixel-perfect edges
        g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF);

        // Set color and stroke
        g2d.setColor(outlineColor);
        g2d.setStroke(new BasicStroke(lineThickness));

        // To avoid clipping, draw inside the bounds.
        // Adjust for stroke thickness to stay within image bounds.
        float halfStroke = lineThickness / 2f;
        g2d.drawRect(
                Math.round(halfStroke),
                Math.round(halfStroke),
                Math.round(width - lineThickness),
                Math.round(height - lineThickness)
        );

        g2d.dispose();
        return image;
    }
}
