GraphicsAPI reference
Class RendererExtensions
Namespace: MicroEngine.Graphics
Assembly: MicroEngine.Graphics2D.dll
Guide: Graphics
Drawing helpers built on IRenderer: sprites, outlines, ellipses, gradients and panels.
public static class RendererExtensionsInheritance
Methods
Draw(IRenderer, Sprite, Vector2, Color?, bool)
Draws a sprite so its Origin lands on position.
public static void Draw(this IRenderer r, Sprite sprite, Vector2 position, Color? tint = null, bool flipX = false)Parameters
The renderer.
sprite Sprite
The sprite.
position Vector2
Where the sprite’s origin goes, in virtual (or camera world) pixels.
tint Color?
Colour multiplier; null for white (unchanged).
flipX bool
Mirrors the sprite horizontally; the origin is mirrored too, so the sprite turns around its anchor.
Draw(IRenderer, Texture, Vector2, Color?)
Draws a whole texture with its top-left at position.
public static void Draw(this IRenderer r, Texture texture, Vector2 position, Color? tint = null)Parameters
texture Texture
position Vector2
tint Color?
DrawNineSlice(IRenderer, NineSlice, RectF, Color?)
Draws slice over destination: its four corners at their size (times
Scale), its edges stretched along the sides and its centre stretched to fill the rest. A
destination smaller than the corners shrinks them to fit.
public static void DrawNineSlice(this IRenderer r, NineSlice slice, RectF destination, Color? tint = null)Parameters
The renderer.
slice NineSlice
The image and its borders.
destination RectF
Where it goes, in the renderer’s pixels or UI units.
tint Color?
Colour multiplier; null for white (unchanged).
DrawPivoted(IRenderer, Sprite, Vector2, float, Vector2?, Color?, bool)
Draws a sprite so its origin lands on pivot, rotating and scaling around that
pivot. Use it for squash/stretch, spinning items and anything that must stay anchored at the feet.
public static void DrawPivoted(this IRenderer r, Sprite sprite, Vector2 pivot, float rotation = 0, Vector2? scale = null, Color? tint = null, bool flipX = false)Parameters
sprite Sprite
pivot Vector2
rotation float
scale Vector2?
tint Color?
flipX bool
DrawRect(IRenderer, RectF, Color, float)
Draws the outline of rect, thickness pixels wide, inside the rectangle.
public static void DrawRect(this IRenderer r, RectF rect, Color color, float thickness = 1)Parameters
rect RectF
color Color
thickness float
FillEllipse(IRenderer, Vector2, float, float, Color)
Filled ellipse built from horizontal spans; handy for soft drop shadows.
public static void FillEllipse(this IRenderer r, Vector2 center, float radiusX, float radiusY, Color color)Parameters
center Vector2
radiusX float
radiusY float
color Color
FillGradient(IRenderer, RectF, Color, Color, int)
Vertical gradient approximated with horizontal bands (cheap and pixel-crisp).
public static void FillGradient(this IRenderer r, RectF rect, Color top, Color bottom, int bands = 0)Parameters
rect RectF
top Color
bottom Color
bands int
Panel(IRenderer, RectF, PanelStyle)
Draws a panel: with Image, that image as a nine-slice tinted by ImageTint (its shadow, when set, is the image in the shadow colour 2 pixels down and right); otherwise a rounded “pixel” box of border, fill and an inner highlight line.
public static void Panel(this IRenderer r, RectF rect, PanelStyle style)Parameters
rect RectF
style PanelStyle