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
transformTransform2DThe render context's current transform.
destinationRectangleThe destination rectangle before
transformis applied.rotationfloatThe per-draw rotation in radians, added to the transform's own rotation.
originVector2The per-draw origin; snapping only applies when it is Zero.
positionVector2The snapped top-left corner in physical pixels.
sizeVector2The snapped size in physical pixels.