Пример #1
0
        public static void DrawCenter( this SpriteBatch spriteBatch, Texture2D texture, Vector2D position, NacRectangle? source = null, Color? color = null,
			float rotation = 0, float scale = 1, SpriteEffects effect = SpriteEffects.None, float layerDepth = 0 )
        {
            XnaRectangle? so = source != null ? source.Value.ToXna() : (XnaRectangle?)null;
            Color c = color ?? Color.White;
            Vector2 o = source == null ? texture.Bounds.Center.ToVector2() : ( source.Value.Size / 2 ).ToXna();
            spriteBatch.Draw( texture, position.ToXna(), so, c, rotation, o, scale, effect, layerDepth );
        }
Пример #2
0
        public static void DrawExtend( this SpriteBatch spriteBatch, Texture2D texture, Vector2D position, Vector2D scale, NacRectangle? source = null,
			Color? color = null, float rotation = 0, Vector2D? origin = null, SpriteEffects effect = SpriteEffects.None, float layerDepth = 0 )
        {
            Color c = color ?? Color.White;
            XnaRectangle? s = source != null ? source.Value.ToXna() : (XnaRectangle?)null;
            Vector2 o = ( origin ?? Vector2D.Zero ).ToXna();
            spriteBatch.Draw( texture, position.ToXna(), s, c, rotation, o, scale.ToXna(), effect, layerDepth );
        }
Пример #3
0
 public static void DrawStringCenter( this SpriteBatch spriteBatch, SpriteFont font, string text, Vector2D location, Color color )
 {
     var size = font.MeasureString( text );
     spriteBatch.DrawString( font, text, location.ToXna() - size/2, color );
 }
Пример #4
0
        public void DrawLine( Vector2D begin, Vector2D end, Color color )
        {
            Vector2D draw = new Vector2D( begin.X, begin.Y );
            Vector2D distance = new Vector2D( ( end - begin ).X, ( end - begin ).Y );
            Vector2D diff = new Vector2D();

            diff = distance / Math.Max( Math.Abs( distance.X ), Math.Abs( distance.Y ) );

            for( ; ( draw - begin ).SquaredLength <= distance.SquaredLength; draw += diff )
                spriteBatch.Draw( pixel, draw.ToXna(), color );
        }