package ru.dbotthepony.mc.otm.client.render

import net.minecraft.resources.ResourceLocation

fun ResourceLocation.atlas(
	width: Float,
	height: Float,
	winding: UVWindingOrder = UVWindingOrder.NORMAL,
) = MatteryAtlas(this, width, height, winding)

data class MatteryAtlas(
	val texture: ResourceLocation,
	val width: Float,
	val height: Float,
	val winding: UVWindingOrder = UVWindingOrder.NORMAL,
) {
	fun sprite(
		x: Float = 0f,
		y: Float = 0f,
		width: Float = this.width,
		height: Float = this.height,
		winding: UVWindingOrder = this.winding,
	) = MatterySprite(texture, x = x, y = y, width = width, height = height, atlasHeight = this.height, atlasWidth = this.width, winding = winding)

	fun grid(rows: Int, columns: Int) = GridAtlas(texture, this.width / columns, this.height / rows, rows = rows, columns = columns)
	fun grid(width: Float, height: Float, rows: Int, columns: Int) = GridAtlas(texture, width, height, rows, columns)
}
