All files / player-browser/src/skins/pixi-kit resolution.ts

100% Statements 4/4
100% Branches 4/4
100% Functions 2/2
100% Lines 4/4

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18  52x   52x             4x         6x    
/** Most texels per design pixel text rasterizes at, whatever the display. */
const MAX_TEXT_RESOLUTION = 8;
 
let current = 1;
 
/**
 * Sets the density Pixi-kit text rasterizes at: the surface's canvas pixels per design pixel, so one glyph texel lands
 * on one screen pixel. The Pixi skin adapter calls it before each frame.
 */
export function setTextResolution(pixelRatio: number): void {
  current = Number.isFinite(pixelRatio) && pixelRatio > 0 ? Math.min(MAX_TEXT_RESOLUTION, pixelRatio) : 1;
}
 
/** Density text should rasterize at this frame (see {@link setTextResolution}). */
export function textResolution(): number {
  return current;
}