本文整理汇总了C#中SFML.Graphics.Vector2.Round方法的典型用法代码示例。如果您正苦于以下问题:C# Vector2.Round方法的具体用法?C# Vector2.Round怎么用?C# Vector2.Round使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SFML.Graphics.Vector2
的用法示例。
在下文中一共展示了Vector2.Round方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DrawStringShaded
/// <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);
}
示例2: Begin
/// <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;
}
示例3: Draw
/// <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);
}
示例4: DrawString
/// <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);
}
示例5: Draw
/// <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);
}