npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

kf-player

v1.0.1

Published

Keyframe player from time stamped data sets

Downloads

4

Readme

kf-player Build Status Coverage Status npm version

Keyframe style data replay, used for dynamic eye tracking but can keyframe any data set.

Installation

npm install kf-player

Usage

const player = require('kf-player')();

player.data({
	1000: {entity1: [100,200], entity2: true},
	2000: {entity1: [200,300], entity2: false}	
});

let state = player.at(1.2);

console.log(state.entity1);    // [120,220]
console.log(state.entity2);    // true

Multiple data sets can be given by multiple calls to .data(). Any number of entities can be used, and don't need to be specified for each key frame. Each entity can be of primitive, object or array data types.

By default linear interpolation is performed on numeric values, this can be changed to "none" or a custom function (more to be added...):

player.data({
	entities: {
		entity1: {
			interpolation: function(previous,next,percent) { ... }
		}
	},
	1000: {entity1: [100,200], entity2: true},
	2000: {entity1: [200,300], entity2: false}	
});

Alternative data formats can also be used, for example a format compatible with loading csv or similar data (see csvtojson):

player.data({
	timestamp: "TIME",    // Property name
	data: [
		{TIME: 100, x1: 200, y1: 200, x2: 300, y2: 200},
		{TIME: 200, x1: 240, y1: 320, x2: 300, y2: 210}
	]
});

API

.at(t)

Get the state of all entities at the time t, where t is in seconds. It returns an object with a property for each entity and where the values for each entity have been appropriately (as specified) interpolated.

.duration()

Return total animation duration in seconds.

console.log(player.duration());    // 5.4

.entities()

Return a list of all entities in the animation.

.frameCount()

Return the number of keyframes.

.begin([time])

Start a new animation sequence. Optional: give a time in seconds to start at.

.end()

Finish an animation.

.frame()

Get the state of the animation at the current frame. The frame to return is calculated from the system clock and animation speed. To get a specific point in the animation, use the .at(t) function.

.speed(s)

Set the speed as a multiplier. eg. 2 runs the animation at 2x natural speed. Using no arguments, this function returns the current speed.