GraphicsAPI reference
Class Presentation
Namespace: MicroEngine.Graphics
Assembly: MicroEngine.Graphics.dll
Guide: Presentation
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.
public sealed record Presentation : IEquatable<Presentation>Inheritance
Implements
Constructors
Presentation()
public Presentation()Properties
Aspect
Keep the canvas’s shape (letterbox) or stretch it to the window.
public AspectMode Aspect { get; init; }Property Value
CameraPixelSnap
Whether 2D cameras created for this presentation round their translation to whole canvas pixels
(Camera2D.PixelSnap): crisp pixel art (PixelArt), smooth motion for high-resolution art
(HighResolution2D). Each camera can still change it.
public bool CameraPixelSnap { get; init; }Property Value
CaptureScale
Size factor of the captures a run writes (screenshots, scripted captures): 1 is the canvas’s own size.
public int CaptureScale { get; init; }Property Value
Exceptions
The value is less than 1.
DefaultSampler
The sampler of textures, atlases and font pages created without a filter of their own: the game’s explicit default, written down instead of implied by another option.
public SamplerDescription DefaultSampler { get; init; }Property Value
HighResolution2D
High-resolution 2D: the largest size of the canvas’s shape that fits, letterboxed, linear sampling for the canvas and for textures, captures at the canvas’s size, cameras moving smoothly (no snap).
public static Presentation HighResolution2D { get; }Property Value
PixelArt
Pixel art: whole factors unless they waste more than a fifth of the window, letterboxed, nearest sampling for the canvas and for textures, captures three times the canvas, windows opened at whole factors, cameras snapped to whole pixels.
public static Presentation PixelArt { get; }Property Value
Rounding
How the scale is rounded.
public ScaleRounding Rounding { get; init; }Property Value
UiScale
Window pixels per UI unit of the UI view, drawn over the world at the window’s resolution. Null (the default) follows the surface’s pixel density (PixelDensity): 1 on an ordinary screen, 2 on a screen with twice the pixels per logical unit, so the interface keeps its physical size; the headless platform’s density is 1. A value overrides the density: 1 draws one UI unit per window pixel everywhere, 2 makes the UI twice as large. Platforms resolve it with UiScaleFor.
public float? UiScale { get; init; }Property Value
Exceptions
The value is not null and not a positive finite number.
Upscale
How the canvas is sampled when it is drawn to the window at another size.
public SamplerDescription Upscale { get; init; }Property Value
WastefulThreshold
With IntegerUnlessWasteful: the share of the fitting size a whole factor must fill (0.8 by default, so a whole factor is kept when it fills at least 80 % of what would fit).
public float WastefulThreshold { get; init; }Property Value
Exceptions
The value is not within 0..1.
WholeFactorWindows
Whether desktop windows open at a whole factor of the canvas when the requested size does not fit the display.
public bool WholeFactorWindows { get; init; }Property Value
Methods
<Clone>$()
public Presentation <Clone>$()Returns
CanvasSize(RectF, int, int)
The canvas size for area: the configured size, except with Expand,
where the side the window has room for grows (at the scale Rounding chooses) until the scaled canvas
fills the area. Never smaller than the configured size.
public (int Width, int Height) CanvasSize(RectF area, int canvasWidth, int canvasHeight)Parameters
area RectF
canvasWidth int
canvasHeight int
Returns
Exceptions
The configured size is not positive.
Equals(object?)
public override bool Equals(object? obj)Parameters
obj object?
Returns
Equals(Presentation?)
public bool Equals(Presentation? other)Parameters
other Presentation?
Returns
Fit(RectF, int, int, bool)
Where the canvas lands in area (the window, or its safe area on a phone), in window pixels: the
largest scale that fits, rounded by Rounding, centred; with portrait it sits at the
top of the area instead (on-screen controls get the space below). With Stretch it covers
the whole area.
public RectF Fit(RectF area, int canvasWidth, int canvasHeight, bool portrait = false)Parameters
area RectF
The area available, in window pixels.
canvasWidth int
The canvas’s width in pixels.
canvasHeight int
The canvas’s height in pixels.
portrait bool
Whether the screen is portrait (taller than wide by more than a tenth).
Returns
Exceptions
The canvas size is not positive.
Fit(Vector2, RectF, int, int)
Where the canvas lands in a window of window pixels whose usable part is
safeArea (an empty safe area means the whole window): Fit
in the safe area, at its top when the window is portrait (taller than wide by more than a tenth). Every backend
places its frame with this method, so they agree.
public RectF Fit(Vector2 window, RectF safeArea, int canvasWidth, int canvasHeight)Parameters
window Vector2
safeArea RectF
canvasWidth int
canvasHeight int
Returns
GetHashCode()
public override int GetHashCode()Returns
ToCanvas(Vector2, RectF, int, int)
A window position in canvas pixels, for a canvas drawn at frame.
public static Vector2 ToCanvas(Vector2 window, RectF frame, int canvasWidth, int canvasHeight)Parameters
window Vector2
frame RectF
canvasWidth int
canvasHeight int
Returns
ToString()
public override string ToString()Returns
UiScaleFor(float)
The UI scale on a surface of pixelDensity: UiScale when it is set, else the density
(1 when the density is not a positive finite number).
public float UiScaleFor(float pixelDensity)Parameters
pixelDensity float
Returns
Operators
operator ==(Presentation?, Presentation?)
public static bool operator ==(Presentation? left, Presentation? right)Parameters
left Presentation?
right Presentation?
Returns
operator !=(Presentation?, Presentation?)
public static bool operator !=(Presentation? left, Presentation? right)Parameters
left Presentation?
right Presentation?