MCPcopy Create free account
hub / github.com/NativeScript/SimDeck / computeScale

Function computeScale

packages/client/src/features/viewport/viewportMath.ts:210–236  ·  view source on GitHub ↗
(
  canvasSize: Size | null,
  deviceNaturalSize: Size | null,
  marginX: number,
  marginY: number,
  chromeProfile: ChromeProfile | null,
  reservedBottomInset = 0,
  rotationQuarterTurns = 0,
)

Source from the content-addressed store, hash-verified

208}
209
210function computeScale(
211 canvasSize: Size | null,
212 deviceNaturalSize: Size | null,
213 marginX: number,
214 marginY: number,
215 chromeProfile: ChromeProfile | null,
216 reservedBottomInset = 0,
217 rotationQuarterTurns = 0,
218): number {
219 if (!canvasSize) {
220 return 1;
221 }
222 const totalSize = shellSize(
223 deviceNaturalSize,
224 chromeProfile,
225 rotationQuarterTurns,
226 );
227 const availableWidth = Math.max(canvasSize.width - marginX * 2, 0);
228 const availableHeight = Math.max(
229 canvasSize.height - marginY * 2 - reservedBottomInset,
230 0,
231 );
232 return Math.min(
233 availableWidth / totalSize.width,
234 availableHeight / totalSize.height,
235 );
236}
237
238export function computeFitScale(
239 canvasSize: Size | null,

Callers 2

computeFitScaleFunction · 0.85
computeCenterScaleFunction · 0.85

Calls 2

shellSizeFunction · 0.85
maxMethod · 0.80

Tested by

no test coverage detected