Nez.Portable/PipelineRuntime/BitmapFonts/BitmapFont.cs
/// <summary>
/// old SpriteBatch drawing method. This should probably be removed since SpriteBatch was replaced by Batcher
/// </summary>
/// <param name="spriteBatch">Sprite batch.</param>
/// <param name="text">Text.</param>
/// <param name="position">Position.</param>
/// <param name="color">Color.</param>
/// <param name="rotation">Rotation.</param>
/// <param name="origin">Origin.</param>
/// <param name="scale">Scale.</param>
/// <param name="effect">Effect.</param>
/// <param name="depth">Depth.</param>
old SpriteBatch drawing method. This should probably be removed since SpriteBatch was replaced by Batcher
old SpriteBatch drawing method . This should probably be removed since SpriteBatch was replaced by Batcher
internal void drawInto(
            SpriteBatch spriteBatch,
            ref FontCharacterSource text,
            Vector2 position,
            Color color,
            float rotation,
            Vector2 origin,
            Vector2 scale,
            SpriteEffects effect,
            float depth)
        {
            var flipAdjustment = Vector2.Zero;
            var flippedVert = (effect & SpriteEffects.FlipVertically) == SpriteEffects.FlipVertically;
            var flippedHorz = (effect & SpriteEffects.FlipHorizontally) == SpriteEffects.FlipHorizontally;
            if (flippedVert || flippedHorz)
            {
                Vector2 size;
                measureString(ref text, out size);
                if (flippedHorz)
                {
                    origin.X *= -1;
                    flipAdjustment.X = -size.X;
                }
                if (flippedVert)
                {
                    origin.Y *= -1;
                    flipAdjustment.Y = lineHeight - size.Y;
                }
            }
            var requiresTransformation = flippedHorz || flippedVert || rotation != 0f || scale != Vector2.One;
            if (requiresTransformation)
            {
                Matrix2D temp;
                Matrix2D.createTranslation(-origin.X, -origin.Y, out _transformationMatrix);
                Matrix2D.createScale(flippedHorz ? -scale.X : scale.X, flippedVert ? -scale.Y : scale.Y, out temp);
                Matrix2D.multiply(ref _transformationMatrix, ref temp, out _transformationMatrix);
                Matrix2D.createTranslation(flipAdjustment.X, flipAdjustment.Y, out temp);
                Matrix2D.multiply(ref temp, ref _transformationMatrix, out _transformationMatrix);
                Matrix2D.createRotation(rotation, out temp);
                Matrix2D.multiply(ref _transformationMatrix, ref temp, out _transformationMatrix);
                Matrix2D.createTranslation(position.X, position.Y, out temp);
                Matrix2D.multiply(ref _transformationMatrix, ref temp, out _transformationMatrix);
            }
            BitmapFontRegion currentFontRegion = null;
            var offset = requiresTransformation ? Vector2.Zero : position - origin;
            for (var i = 0; i < text.Length; ++i)
            {
                var c = text[i];
                if (c == '\r')
                    continue;
                if (c == '\n')
                {
                    offset.X = requiresTransformation ? 0f : position.X - origin.X;
                    offset.Y += lineHeight;
                    currentFontRegion = null;
                    continue;
                }
                if (currentFontRegion != null)
                    offset.X += spacing + currentFontRegion.xAdvance;
                if (!_characterMap.TryGetValue(c, out currentFontRegion))
                    currentFontRegion = defaultCharacterRegion;
                var p = offset;
                if (flippedHorz)
                    p.X += currentFontRegion.width;
                p.X += currentFontRegion.xOffset;
                if (flippedVert)
                    p.Y += currentFontRegion.height - lineHeight;
                p.Y += currentFontRegion.yOffset;
                if (requiresTransformation)
                    Vector2Ext.transform(ref p, ref _transformationMatrix, out p);
                var destRect = RectangleExt.fromFloats(
                    p.X,
                    p.Y,
                    currentFontRegion.width * scale.X,
                    currentFontRegion.height * scale.Y);
                spriteBatch.Draw(
                    currentFontRegion.subtexture,
                    destRect,
                    currentFontRegion.subtexture.sourceRect,
                    color,
                    rotation,
                    Vector2.Zero,
                    effect,
                    depth);
            }
        }
internal void drawInto ( SpriteBatch spriteBatch , ref FontCharacterSource text , Vector2 position , Color color , float rotation , Vector2 origin , Vector2 scale , SpriteEffects effect , float depth ) { var flipAdjustment = Vector2 . Zero ; var flippedVert = ( effect & SpriteEffects . FlipVertically ) == SpriteEffects . FlipVertically ; var flippedHorz = ( effect & SpriteEffects . FlipHorizontally ) == SpriteEffects . FlipHorizontally ; if ( flippedVert || flippedHorz ) { Vector2 size ; measureString ( ref text , out size ) ; if ( flippedHorz ) { origin . X *= - 1 ; flipAdjustment . X = - size . X ; } if ( flippedVert ) { origin . Y *= - 1 ; flipAdjustment . Y = lineHeight - size . Y ; } } var requiresTransformation = flippedHorz || flippedVert || rotation != 0f || scale != Vector2 . One ; if ( requiresTransformation ) { Matrix2D temp ; Matrix2D . createTranslation ( - origin . X , - origin . Y , out _transformationMatrix ) ; Matrix2D . createScale ( flippedHorz ? - scale . X : scale . X , flippedVert ? - scale . Y : scale . Y , out temp ) ; Matrix2D . multiply ( ref _transformationMatrix , ref temp , out _transformationMatrix ) ; Matrix2D . createTranslation ( flipAdjustment . X , flipAdjustment . Y , out temp ) ; Matrix2D . multiply ( ref temp , ref _transformationMatrix , out _transformationMatrix ) ; Matrix2D . createRotation ( rotation , out temp ) ; Matrix2D . multiply ( ref _transformationMatrix , ref temp , out _transformationMatrix ) ; Matrix2D . createTranslation ( position . X , position . Y , out temp ) ; Matrix2D . multiply ( ref _transformationMatrix , ref temp , out _transformationMatrix ) ; } BitmapFontRegion currentFontRegion = null ; var offset = requiresTransformation ? Vector2 . Zero : position - origin ; for ( var i = 0 ; i < text . Length ; ++ i ) { var c = text [ i ] ; if ( c == ' \r ' ) continue ; if ( c == ' \n ' ) { offset . X = requiresTransformation ? 0f : position . X - origin . X ; offset . Y += lineHeight ; currentFontRegion = null ; continue ; } if ( currentFontRegion != null ) offset . X += spacing + currentFontRegion . xAdvance ; if ( ! _characterMap . TryGetValue ( c , out currentFontRegion ) ) currentFontRegion = defaultCharacterRegion ; var p = offset ; if ( flippedHorz ) p . X += currentFontRegion . width ; p . X += currentFontRegion . xOffset ; if ( flippedVert ) p . Y += currentFontRegion . height - lineHeight ; p . Y += currentFontRegion . yOffset ; if ( requiresTransformation ) Vector2Ext . transform ( ref p , ref _transformationMatrix , out p ) ; var destRect = RectangleExt . fromFloats ( p . X , p . Y , currentFontRegion . width * scale . X , currentFontRegion . height * scale . Y ) ; spriteBatch . Draw ( currentFontRegion . subtexture , destRect , currentFontRegion . subtexture . sourceRect , color , rotation , Vector2 . Zero , effect , depth ) ; } }
old SpriteBatch drawing method.
old SpriteBatch drawing method .
// transform our point if we need to
spriteBatch
SpriteBatch
None
FontCharacterSource
ref
position
Vector2
None
color
Color
None
rotation
float
None
origin
Vector2
None
scale
Vector2
None
effect
SpriteEffects
None
depth
float
None
text
None