I2DRenderUtilitiesΒΆ

interface I2DRenderUtilities

The 2DRenderUtilities interface.

Vector2 MeasureText(IRenderContext context, string text, Protogame.IAssetReference<FontAsset> font)

Measures text as if it was rendered with the font asset.

Parameters:
  • context (Protogame.IRenderContext) – The rendering context.
  • text (string) – The text to render.
  • font (Protogame.IAssetReference<FontAsset>) – The font to use for rendering.
Returns:

The T:Microsoft.Xna.Framework.Vector2.

void RenderLine(IRenderContext context, Vector2 start, Vector2 end, Color color, float width)

Renders a 2D line.

Parameters:
  • context (Protogame.IRenderContext) – The rendering context.
  • start (Microsoft.Xna.Framework.Vector2) – The start of the line.
  • end (Microsoft.Xna.Framework.Vector2) – The end of the line.
  • color (Microsoft.Xna.Framework.Color) – The color of the line.
  • width (float) – The width of the line (defaults to 1).
void RenderRectangle(IRenderContext context, Rectangle rectangle, Color color, bool filled)

Renders a rectangle.

Parameters:
  • context (Protogame.IRenderContext) – The rendering context.
  • rectangle (Microsoft.Xna.Framework.Rectangle) – The rectangle to render.
  • color (Microsoft.Xna.Framework.Color) – The color of the rectangle.
  • filled (bool) – If set to true, the rectangle is rendered filled.
void RenderText(IRenderContext context, Vector2 position, string text, Protogame.IAssetReference<FontAsset> font, HorizontalAlignment horizontalAlignment, VerticalAlignment verticalAlignment, System.Nullable<Color> textColor, bool renderShadow, System.Nullable<Color> shadowColor)

Renders text at the specified position.

Parameters:
  • context (Protogame.IRenderContext) – The rendering context.
  • position (Microsoft.Xna.Framework.Vector2) – The position to render the text.
  • text (string) – The text to render.
  • font (Protogame.IAssetReference<FontAsset>) – The font to use for rendering.
  • horizontalAlignment (Protogame.HorizontalAlignment) – The horizontal alignment of the text (defaults to Left).
  • verticalAlignment (Protogame.VerticalAlignment) – The vertical alignment of the text (defaults to Top).
  • textColor (System.Nullable<Color>) – The text color (defaults to white).
  • renderShadow (bool) – Whether to render a shadow on the text (defaults to true).
  • shadowColor (System.Nullable<Color>) – The text shadow’s color (defaults to black).
void RenderTexture(IRenderContext context, Vector2 position, Protogame.IAssetReference<TextureAsset> texture, System.Nullable<Vector2> size, System.Nullable<Color> color, float rotation, System.Nullable<Vector2> rotationAnchor, bool flipHorizontally, bool flipVertically, System.Nullable<Rectangle> sourceArea)

Renders a texture at the specified position.

Parameters:
  • context (Protogame.IRenderContext) – The rendering context.
  • position (Microsoft.Xna.Framework.Vector2) – The position to render the texture.
  • texture (Protogame.IAssetReference<TextureAsset>) – The texture.
  • size (System.Nullable<Vector2>) – The size to render the texture as (defaults to the texture size).
  • color (System.Nullable<Color>) – The colorization to apply to the texture.
  • rotation (float) – The rotation to apply to the texture.
  • rotationAnchor (System.Nullable<Vector2>) – The anchor for rotation, or null to use the top-left corner.
  • flipHorizontally (bool) – If set to true the texture is flipped horizontally.
  • flipVertically (bool) – If set to true the texture is flipped vertically.
  • sourceArea (System.Nullable<Rectangle>) – The source area of the texture (defaults to the full texture).
void RenderTexture(IRenderContext context, Vector2 position, Texture2D texture, System.Nullable<Vector2> size, System.Nullable<Color> color, float rotation, System.Nullable<Vector2> rotationAnchor, bool flipHorizontally, bool flipVertically, System.Nullable<Rectangle> sourceArea)

Renders a texture at the specified position.

Parameters:
  • context (Protogame.IRenderContext) – The rendering context.
  • position (Microsoft.Xna.Framework.Vector2) – The position to render the texture.
  • texture (Microsoft.Xna.Framework.Graphics.Texture2D) – The texture.
  • size (System.Nullable<Vector2>) – The size to render the texture as (defaults to the texture size).
  • color (System.Nullable<Color>) – The colorization to apply to the texture.
  • rotation (float) – The rotation to apply to the texture.
  • rotationAnchor (System.Nullable<Vector2>) – The anchor for rotation, or null to use the top-left corner.
  • flipHorizontally (bool) – If set to true the texture is flipped horizontally.
  • flipVertically (bool) – If set to true the texture is flipped vertically.
  • sourceArea (System.Nullable<Rectangle>) – The source area of the texture (defaults to the full texture).
void RenderCircle(IRenderContext context, Vector2 center, int radius, Color color, bool filled)

Renders a circle.

Parameters:
  • context (Protogame.IRenderContext) – The rendering context.
  • center (Microsoft.Xna.Framework.Vector2) – The center of the circle.
  • radius (int) – The radius of the circle.
  • color (Microsoft.Xna.Framework.Color) – The color of the circle.
  • filled (bool) – If set to true, the circle is rendered filled.
void SuspendSpriteBatch(IRenderContext renderContext)

Suspends usage of the sprite batch so that direct rendering can occur during a 2D context.

Parameters:
  • renderContext (Protogame.IRenderContext) – The current rendering context.
void ResumeSpriteBatch(IRenderContext renderContext)

Resumes usage of the sprite batch again.

Parameters:
  • renderContext (Protogame.IRenderContext) – The current rendering context.