Skip to content

1681-engine / react / pixelFit

Function: pixelFit() ​

ts
function pixelFit(
   w, 
   h, 
   boxW, 
   boxH, 
   maxScale?
): Size & object;

Defined in: src/react/placement.ts:84

A sprite of w × h art pixels at the largest whole multiple that fits the box (never past maxScale), or a whole divisor when it is bigger than the box: object-fit: contain stretched a 26-px sprite by 2.77 and drew its pixels two and three screen pixels wide by turns.

Parameters ​

ParameterTypeDefault value
wnumberundefined
hnumberundefined
boxWnumberundefined
boxHnumberundefined
maxScalenumberInfinity

Returns ​

Size & object

Released under the MIT License.