Table of Contents

Class PixelSnapping

Namespace
Icy.Rendering
Assembly
IcyUI.dll

Provides pixel snapping for axis-aligned quads, shared by every engine's Draw(ITexture, in TextureRenderingOptions) implementation.

public static class PixelSnapping
Inheritance
PixelSnapping
Inherited Members

Remarks

Snapping rounds the quad's edges (left/top and right/bottom) to whole physical pixels, rather than its position and size separately. Two quads that share an edge in logical units therefore share it in physical pixels at any scale (e.g. 125 % or 150 %), so no seams or 1-pixel gaps appear, and linearly sampled textures aren't blurred by sub-pixel offsets.

Methods

TrySnap(in Transform2D, Rectangle, float, Vector2, out Vector2, out Vector2)

Tries to snap a destination rectangle, transformed by transform, to whole physical pixels.

public static bool TrySnap(in Transform2D transform, Rectangle destination, float rotation, Vector2 origin, out Vector2 position, out Vector2 size)

Parameters

transform Transform2D

The render context's current transform.

destination Rectangle

The destination rectangle before transform is applied.

rotation float

The per-draw rotation in radians, added to the transform's own rotation.

origin Vector2

The per-draw origin; snapping only applies when it is Zero.

position Vector2

The snapped top-left corner in physical pixels.

size Vector2

The snapped size in physical pixels.

Returns

bool

true if the quad is axis-aligned with a positive scale and was snapped; false (and default outputs) when it is rotated, mirrored or has a non-zero origin, in which case the caller draws it unsnapped.