using UnityEngine;

namespace mgaia.tk2d
{
	/// <summary>
	/// Extensões para Tk2dBaseSprite
	/// </summary>
	public static class Tk2dBaseSpriteExtensions
	{
		/// <summary>
		/// Retorna o tamanho real da sprite
		/// </summary>
		/// <owner>Victor</owner>
		public static Bounds GetRealBounds(this tk2dBaseSprite baseSprite)
		{
			tk2dSpriteDefinition spriteDefinition = baseSprite.GetCurrentSpriteDef();

			Bounds spriteBounds = spriteDefinition.GetBounds();
			Vector2 texelSize = spriteDefinition.texelSize;
			Vector2 size = new Vector2(spriteBounds.size.x / texelSize.x, spriteBounds.size.y / texelSize.y);

			return new Bounds(size / 2, size);
		}
	}
}