Beispiel #1
0
		protected void SetTextureStacksAndSlices( int stacks, int slices )
		{
			if ( stacks == 0 )
			{
				stacks = 1;
			}
			if ( slices == 0 )
			{
				slices = 1;
			}
			//  clear out any previous allocation
			this.textureCoords.Clear();
			//  make room
			this.textureCoords.Capacity = stacks * slices;
			while ( this.textureCoords.Count < stacks * slices )
			{
				this.textureCoords.Add( new RectangleF() );
			}
			ushort coordIndex = 0;
			//  spread the U and V coordinates across the rects
			for ( uint v = 0; v < stacks; ++v )
			{
				//  (float)X / X is guaranteed to be == 1.0f for X up to 8 million, so
				//  our range of 1..256 is quite enough to guarantee perfect coverage.
				float top = (float)v / (float)stacks;
				float bottom = ( (float)v + 1 ) / (float)stacks;
				for ( uint u = 0; u < slices; ++u )
				{
					RectangleF r = new RectangleF();
					r.Left = (float)u / (float)slices;
					r.Top = top;
					r.Width = ( (float)u + 1 ) / (float)slices - r.Left;
					r.Height = bottom - top;
					this.textureCoords[ coordIndex ] = r;
					++coordIndex;
				}
			}
			Debug.Assert( coordIndex == stacks * slices );
		}
Beispiel #2
0
		internal static RectangleF Intersect( RectangleF lhs, RectangleF rhs )
		{
			RectangleF r;

			r._left = lhs._left > rhs._left ? lhs._left : rhs._left;
			r._top = lhs._top > rhs._top ? lhs._top : rhs._top;
			r._right = lhs._right < rhs._right ? lhs._right : rhs._right;
			r._bottom = lhs._bottom < rhs._bottom ? lhs._bottom : rhs._bottom;

			return r;
		}
Beispiel #3
0
			public GlyphInfo( CodePoint id, UVRect rect, Real aspect )
			{
				this.codePoint = id;
				this.uvRect = rect;
				this.aspectRatio = aspect;
			}
Beispiel #4
0
		public RectangleF Merge( RectangleF rhs )
		{
			if ( Width == 0 )
			{
				this = rhs;
			}
			else
			{
				Left = System.Math.Min( Left, rhs.Left );
				Right = System.Math.Max( Right, rhs.Right );
				Top = System.Math.Min( Top, rhs.Top );
				Bottom = System.Math.Max( Bottom, rhs.Bottom );
			}

			return this;
		}
Beispiel #5
0
		public RectangleF Intersect( RectangleF rhs )
		{
			return Intersect( this, rhs );
		}
Beispiel #6
0
		public RectangleF( RectangleF copy )
		{
			_left = copy._left;
			_top = copy._top;
			_right = copy._right;
			_bottom = copy._bottom;
		}
Beispiel #7
0
 public GlyphInfo(CodePoint id, UVRect rect, Real aspect)
 {
     this.codePoint   = id;
     this.uvRect      = rect;
     this.aspectRatio = aspect;
 }
Beispiel #8
0
			public GlyphInfo( CodePoint id, UVRect rect, Real aspect )
			{
				codePoint = id;
				uvRect = rect;
				aspectRatio = aspect;
			}