Function points

Track several named points over time, eg a TensorFlow body pose point. Call seen() to track a point. Mutable. If you want to compare a single coordinate with a reference coordinate, point may be a better choice.

See also:

Basic usage

import { points } from 'https://unpkg.com/ixfx/dist/trackers.js';

const pt = points();

// Track a point under a given id
document.addEventListener(`pointermove`, e => {
const info = await pt.seen(e.pointerId, { x: e.x, y: e.y });
// Yields some info on relation of the point to initial value
});

Do something with last values for all points

const c = Points.centroid(...Array.from(pt.last()));

More functions...

pt.size;       // How many named points are being tracked
pt.delete(id); // Delete named point
pt.reset(); // Clear data

Accessing by id:

pt.get(id);  // Get named point (or _undefined_)
pt.has(id); // Returns true if id exists

Iterating over data

pt.trackedByAge(); // Iterates over tracked points, sorted by age (oldest first)
pt.tracked(); // Tracked values
pt.ids(); // Iterator over ids

// Last received value for each named point
pt.last();

pt.initialValues(); // Iterator over initial values for each point

You can work with 'most recently updated' points:

// Iterates over points, sorted by age (oldest first)
pt.valuesByAge();

Options:

  • id: Id of this tracker. Optional
  • sampleLimit: How many samples to store
  • storeIntermediate: If true, all points are stored internally
  • resetAfterSamples: If set above 0, it will automatically reset after the given number of samples have been seen