MCPcopy
hub / github.com/donmccurdy/glTF-Transform / fitPowerOfTwo

Function fitPowerOfTwo

packages/functions/src/utils.ts:341–354  ·  view source on GitHub ↗
(size: vec2, method: ResizePreset)

Source from the content-addressed store, hash-verified

339 * @hidden
340 */
341export function fitPowerOfTwo(size: vec2, method: ResizePreset): vec2 {
342 if (isPowerOfTwo(size[0]) && isPowerOfTwo(size[1])) {
343 return size;
344 }
345
346 switch (method) {
347 case 'nearest-pot':
348 return size.map(nearestPowerOfTwo) as vec2;
349 case 'ceil-pot':
350 return size.map(ceilPowerOfTwo) as vec2;
351 case 'floor-pot':
352 return size.map(floorPowerOfTwo) as vec2;
353 }
354}
355
356function isPowerOfTwo(value: number): boolean {
357 if (value <= 2) return true;

Callers 3

toktxFunction · 0.90
_encodeWithSharpFunction · 0.85
_encodeWithNdarrayPixelsFunction · 0.85

Calls 1

isPowerOfTwoFunction · 0.85

Tested by

no test coverage detected