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

Function centerOfFirstRoot

scripts/integration/android.mjs:915–940  ·  view source on GitHub ↗
(payload)

Source from the content-addressed store, hash-verified

913}
914
915function centerOfFirstRoot(payload) {
916 const frame = payload?.roots?.[0]?.frame;
917 if (!frame || typeof frame !== "object") {
918 return null;
919 }
920 const x = Number(
921 Array.isArray(frame) ? frame[0] : (frame.x ?? frame.minX ?? 0),
922 );
923 const y = Number(
924 Array.isArray(frame) ? frame[1] : (frame.y ?? frame.minY ?? 0),
925 );
926 const width = Number(Array.isArray(frame) ? frame[2] : (frame.width ?? 0));
927 const height = Number(Array.isArray(frame) ? frame[3] : (frame.height ?? 0));
928 if (
929 !Number.isFinite(width) ||
930 !Number.isFinite(height) ||
931 width <= 0 ||
932 height <= 0
933 ) {
934 return null;
935 }
936 return {
937 x: Math.round(x + width / 2),
938 y: Math.round(y + height / 2),
939 };
940}
941
942function assertPngBuffer(buffer) {
943 const signature = Buffer.from([

Callers 1

runCliSurfaceFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected