/// <summary> /// Draws a string with shading. /// </summary> /// <param name="spriteBatch"><see cref="ISpriteBatch"/> to use to draw.</param> /// <param name="font"><see cref="Font"/> to draw the string with.</param> /// <param name="text">The string to draw.</param> /// <param name="position">The position of the top-left corner of the string to draw.</param> /// <param name="fontColor">The font color.</param> /// <param name="borderColor">The shading color.</param> public static void DrawStringShaded(this ISpriteBatch spriteBatch, Font font, string text, Vector2 position, Color fontColor, Color borderColor) { position = position.Round(); spriteBatch.DrawString(font, text, position - new Vector2(0, 1), borderColor); spriteBatch.DrawString(font, text, position - new Vector2(1, 0), borderColor); spriteBatch.DrawString(font, text, position + new Vector2(0, 1), borderColor); spriteBatch.DrawString(font, text, position + new Vector2(1, 0), borderColor); spriteBatch.DrawString(font, text, position, fontColor); }
/// <summary> /// Prepares the graphics device for drawing sprites with specified blending, sorting, and render state options, /// and a global transform matrix. /// </summary> /// <param name="blendMode">Blending options to use when rendering.</param> /// <param name="position">The top-left corner of the view area.</param> /// <param name="size">The size of the view area.</param> /// <param name="rotation">The amount to rotation the view in degrees.</param> public void Begin(BlendMode blendMode, Vector2 position, Vector2 size, float rotation) { position = position.Round(); size = size.Round(); _view.Reset(new FloatRect(position.X, position.Y, size.X, size.Y)); _view.Rotate(rotation); _rt.SetView(_view); _renderState.BlendMode = blendMode; _isStarted = true; }
/// <summary> /// Adds a sprite to the batch of sprites to be rendered, specifying the texture, destination, and source rectangles, /// color tint, rotation, origin, effects, and sort depth. /// </summary> /// <param name="texture">The sprite texture.</param> /// <param name="position">The location, in screen coordinates, where the sprite will be drawn.</param> /// <param name="sourceRectangle">A rectangle specifying, in texels, which section of the rectangle to draw. /// Use null to draw the entire texture.</param> /// <param name="color">The color channel modulation to use. Use <see cref="Color.White"/> for full color with /// no tinting.</param> /// <param name="rotation">The angle, in radians, to rotate the sprite around the origin.</param> /// <param name="origin">The origin of the sprite. Specify (0,0) for the upper-left corner.</param> /// <param name="scale">Vector containing separate scalar multiples for the x- and y-axes of the sprite.</param> /// <param name="effects">Rotations to apply prior to rendering.</param> /// <param name="shader">The shader to use on the text being drawn.</param> public override void Draw(Image texture, Vector2 position, Rectangle? sourceRectangle, Color color, float rotation, Vector2 origin, Vector2 scale, SpriteEffects effects = SpriteEffects.None, Shader shader = null) { base.Draw(texture, position.Round(), sourceRectangle, color, rotation, origin, scale, effects, shader); }
/// <summary> /// Adds a sprite to the batch of sprites to be rendered, specifying the texture, destination, and source rectangles, /// color tint, rotation, origin, effects, and sort depth. /// </summary> /// <param name="texture">The sprite texture.</param> /// <param name="position">The location, in screen coordinates, where the sprite will be drawn.</param> /// <param name="sourceRectangle">A rectangle specifying, in texels, which section of the rectangle to draw. /// Use null to draw the entire texture.</param> /// <param name="color">The color channel modulation to use. Use <see cref="Color.White"/> for full color with /// no tinting.</param> /// <param name="shader">The shader to use on the text being drawn.</param> public override void Draw(Image texture, Vector2 position, Rectangle? sourceRectangle, Color color, Shader shader = null) { base.Draw(texture, position.Round(), sourceRectangle, color, shader); }
/// <summary> /// Adds a mutable sprite string to the batch of sprites to be rendered, specifying the font, output text, /// screen position, color tint, rotation, origin, scale, effects, and depth. /// </summary> /// <param name="font">The <see cref="Font"/> to use to draw.</param> /// <param name="text">The mutable (read/write) string to draw.</param> /// <param name="position">The location, in screen coordinates, where the text will be drawn.</param> /// <param name="color">The desired color of the text.</param> /// <param name="rotation">The angle, in radians, to rotate the text around the origin.</param> /// <param name="origin">The origin of the string. Specify (0,0) for the upper-left corner.</param> /// <param name="scale">Vector containing separate scalar multiples for the x- and y-axes of the sprite.</param> /// <param name="style">How to style the drawn string.</param> /// <param name="shader">The shader to use on the text being drawn.</param> public override void DrawString(Font font, StringBuilder text, Vector2 position, Color color, float rotation, Vector2 origin, Vector2 scale, Text.Styles style = Text.Styles.Regular, Shader shader = null) { base.DrawString(font, text, position.Round(), color, rotation, origin, scale, style, shader); }
/// <summary> /// Adds a mutable sprite string to the batch of sprites to be rendered, specifying the font, output text, /// screen position, color tint, rotation, origin, scale, effects, and depth. /// </summary> /// <param name="font">The <see cref="Font"/> to use to draw.</param> /// <param name="text">The mutable (read/write) string to draw.</param> /// <param name="position">The location, in screen coordinates, where the text will be drawn.</param> /// <param name="color">The desired color of the text.</param> public override void DrawString(Font font, StringBuilder text, Vector2 position, Color color) { base.DrawString(font, text, position.Round(), color); }
/// <summary> /// Adds a sprite to the batch of sprites to be rendered, specifying the texture, destination, and source rectangles, /// color tint, rotation, origin, effects, and sort depth. /// </summary> /// <param name="texture">The sprite texture.</param> /// <param name="position">The location, in screen coordinates, where the sprite will be drawn.</param> /// <param name="color">The color channel modulation to use. Use <see cref="Color.White"/> for full color with /// no tinting.</param> /// <param name="shader">The shader to use on the text being drawn.</param> public override void Draw(Texture texture, Vector2 position, Color color, Shader shader = null) { base.Draw(texture, position.Round(), color, shader); }