using System;
using System.Collections.Generic;
using System.Text;

namespace Vortex.Drawing {
	/// <summary>
	/// Implementation of brush for using entire texture or its part as pattern
	/// </summary>
	public class TextureBrush : CanvasBrush {

		/// <summary>
		/// Initializes a new instance of the <see cref="TextureBrush"/> class to use entire texture as a brush pattern.
		/// </summary>
		/// <param name="texture">The texture to use as brush pattern.</param>
		public TextureBrush(BaseTexture texture) {
			if (null == texture) throw new ArgumentNullException("texture");

			_patternTexture = texture;
			_region = texture.Region;
			texture.Transform(ref _region, out _transformedRegion);
		}

		/// <summary>
		/// Initializes a new instance of the <see cref="TextureBrush"/> class to use specified region of texture as brush pattern.
		/// </summary>
		/// <param name="texture">The texture pattern.</param>
		/// <param name="region">The untransformed region.</param>
		public TextureBrush(BaseTexture texture, Rect region) {
			if (null == texture) throw new ArgumentNullException("texture");

			_patternTexture = texture;
			_region = region;
			texture.Transform(ref _region, out _transformedRegion);
		}
	}
}
