GraphicsAPI reference
Namespace MicroEngine.Graphics
Drawing: the renderer contract, images in code and from PNG, sprites and atlases, animation, camera, parallax, particles, light, the pixel font.
Guide: Graphics
Namespaces
Classes
An immutable sequence of sprites played at a fixed rate, or with a duration per frame (Aseprite timing).
Plays named clips; switching to the clip already playing does not restart it.
Deterministic helpers for procedural pixel art: hash noise, ordered dithering and palette ramps. Every sample game builds its sprites and tiles from these at load time.
A named run of frames (an Aseprite frame tag).
The description of an atlas image written by a packing tool, read without any graphics device: the JSON of TexturePacker, Free Texture Packer and Aseprite (hash or array of frames; Aseprite’s frame durations and tags), and the Starling/Sparrow XML of TexturePacker, ShoeBox and Kenney’s packs. Trimmed frames keep their place in the untrimmed frame; rotated frames are refused (turn rotation off in the tool).
How atlas files are read.
A proportional pixel font. The built-in face (“Micro 5x7”) is authored in code so every game has crisp, license-free text without loading files. Glyph widths are derived by trimming empty columns, so narrow letters like ‘i’ take less space.
A 2D camera whose Position is the world point at the top-left of the view. Supports smooth following with a dead zone, world bounds and trauma-based shake.
A game’s canvas on a graphics device, as backends built on the device contract use it: the canvas render target, the textures (Graphics) and the drawing API (Renderer) over the 2D batcher, the composition of the canvas into the window as the presentation says, and captures read back from the canvas.
The textures of the drawing API (IGraphicsDevice) made on a graphics device of the device contract: each texture is a device texture whose straight-alpha pixels are premultiplied when they are uploaded, and its Filter chooses the sampler it is drawn with. Backends built on a device use it as their Graphics.
The drawing API (IRenderer) as a façade over the 2D batcher (Renderer2D) on a graphics device: every call is recorded into the batcher, and the frame reaches the device in as few draw calls as the draws’ textures and states allow. Straight-alpha colours are premultiplied on the way in, so the blend modes keep their written equations (see SetBlendMode).
A texture of the drawing API backed by a device texture (DeviceGraphics).
Layout and drawing helpers that work with any IFont.
How a ScalableFont turns outlines into pixels.
Darkness with point lights for caves, dungeons and night scenes. Each frame the game clears the map, adds lights in world space and draws it over the finished scene:
- a coarse brightness grid ([CellSize](/docs/api/microengine.graphics.lightmap/#MicroEngine_Graphics_LightMap_CellSize) pixels, quantised to [Levels](/docs/api/microengine.graphics.lightmap/#MicroEngine_Graphics_LightMap_Levels) bands) is multiplied over the screen, toward [Shade](/docs/api/microengine.graphics.lightmap/#MicroEngine_Graphics_LightMap_Shade) where it is dark;
- lights with a glow colour add a soft radial halo on top.
Rows of equal cells merge into single rectangles, so a full screen costs a few hundred quads. With Darkness 1 and lights of brightness 0 it becomes a flat colour grade plus glows.
A background image that scrolls slower (or faster) than the camera and repeats horizontally. Draw it in screen space (no camera pushed). Factor 0 is fixed to the screen, 1 moves with the world. Y is the screen row of the image’s top edge; the optional VerticalFactor lets tall worlds shift it as the camera rises or falls.
How a burst of particles looks and moves. Ranges are (min, max).
A pooled particle system for dust, sparks, confetti, smoke and the like.
A CPU-side RGBA image. Games author procedural art with it and hand it to CreateTexture; it also backs the built-in font.
Writes 8-bit RGBA PNG files (no filtering), for backends that read frames back as raw pixels.
How the game’s canvas reaches the window, one independent choice per field: how its scale is rounded
(Rounding), what happens to the window’s other shape (Aspect), how it is sampled when it is
scaled (Upscale), the sampler textures get when they choose none (DefaultSampler), the size
factor of captures (CaptureScale), whether desktop windows open at whole factors
(WholeFactorWindows) and whether 2D cameras snap to whole pixels by default
(CameraPixelSnap). PixelArt and HighResolution2D are presets: start from
one and change any field with with.
The engine’s 2D batcher (IRenderer2D) over one graphics device.
Drawing helpers built on IRenderer: sprites, outlines, ellipses, gradients and panels.
A TrueType or OpenType font (TTF, OTF with TrueType or CFF outlines) that draws text at any size. Glyphs are rasterized the first time they are drawn at a size and kept in shared glyph pages (textures), so later frames only draw quads; Prepare rasterizes ahead, so the first frames of play do no font work.
A ShapedFont at one size: an IFont for widgets, layout and drawing.
A TrueType or OpenType font that shapes its text: letters take the forms their neighbours call for (Arabic’s joined forms, Indic conjuncts, ligatures), marks sit where the font places them, and right-to-left scripts (Arabic, Hebrew) run right to left. HarfBuzz chooses the glyphs and their positions; each glyph is rasterized the first time it is drawn at a size and kept in glyph pages (textures), so later frames only draw quads.
A ScalableFont at one size: an IFont for widgets, layout and drawing.
Packs many procedurally authored PixelImages into one texture and exposes them by name. Keeps draw calls batched and art code independent of layout.
Named sprites packed into one texture, built by Build. The atlas owns the texture:
dispose the atlas (usually in Game.Unload) when its sprites are no longer drawn.
A region of a texture with a pivot (origin) in source pixels.
A GPU (or headless) texture owned by the active graphics device.
Structs
One named rectangle of an atlas image, as a packing tool described it.
The settings of one batch, from Begin to End.
Per-draw sprite options. Origin is in source pixels and is also the rotation pivot.
An image that stretches to any size without distorting its frame: the part of Source within Left, Top, Right and Bottom pixels of its sides is the border, drawn at its size at the corners and stretched along the edges; the rest is the centre, stretched to fill. Draw one with DrawNineSlice, or set it as a Image.
The look of a panel drawn with Panel: a box of colours, or an image of the game’s own (Image).
The per-draw state of the 2D batcher (State): blend, sampler and scissor.
Deterministic counts of the last batch (Statistics), the same on every device and run.
One glyph of a shaped line.
Interfaces
Anything that measures and draws text at one size: the built-in BitmapFont (at scale 1) and a ScalableFont at a size (At). UI widgets and layout code take an IFont, so the same code serves pixel-art and HD text.
Creates device resources. Separated so headless tests can provide fakes.
The 2D renderer over the graphics device, implemented once in core: it writes vertices and indices into device buffers and draws them with the built-in Textured pipeline only, so it runs unchanged on every tier. Colours (tints, vertex colours) are premultiplied, and the default blend state is premultiplied alpha.
Immediate-mode 2D drawing in virtual pixels. Coordinates go through the camera pushed with PushCamera; with no camera they are screen space.
Enums
The order an animation plays its frames in (Aseprite’s tag directions).
What happens when the window’s shape differs from the canvas’s (Aspect).
How drawn pixels combine with the canvas (see SetBlendMode): Alpha (normal
transparency, the default), Additive (adds light: glows, sparks, fire) and Multiply (darkens: shadows, tints).
How the canvas’s scale to the window is rounded (Rounding).
The order in which a batch’s draws reach the device (Sort).
Mirrors a sprite’s texels within its quad (Draw).
How a texture is sampled when it is drawn bigger or smaller than its pixels, or between them: Nearest keeps
hard pixel edges (pixel art), Linear blends neighbouring pixels (smooth, high-resolution art and text).