Frame: write your own
[
{
"px": 504,
"py": 0,
"surface_x": 42,
"surface_y": 0
},
{
"px": -282,
"py": 120,
"surface_x": -23.5,
"surface_y": 10
}
]import { type Frame, toSurfaceFrame } from "@sportsdataverse/sporty";
// A Frame is two functions and a description. They see a view { x, y } of the chosen input columns and
// return feet on the surface, or null. Here: a basketball feed in inches from the centre circle.
const inches: Frame = {
x: (r) => (typeof r.x === "number" ? r.x / 12 : null),
y: (r) => (typeof r.y === "number" ? r.y / 12 : null),
description: "inches from centre court",
};
toSurfaceFrame(
[
{ px: 504, py: 0 },
{ px: -282, py: 120 },
],
{ from: inches, x: "px", y: "py" },
);
Tags: frames · toSurfaceFrame · Frame. All sporty examples.