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

@aikuma/gestate

v0.6.2

Published

Gestate gesture recording/playback library

Downloads

30

Readme

Gestate

Gestate is a library for visualising, capturing and playing back touch gestures primarily in support of knowledge performance, i.e. audiovisual presentations. The 'firework' visualisation is intended to be a more useful form of 'pointer' by integrating persistence and emphasizing motion by utilising particle effects that respond to the kinetics of touch input. Gestate is used in the more general Image-Gesture-Voice documentary method based on capturing talk and gesture about a series of images.

project features

  • JavaScript module suitable for integrating with any web app
  • Implements the firework pointer touch visualisation
  • Captures touch (and mouse) events
  • Plays captured events with the firework visualisation
  • Visualisation is computationally inexpensive and suitable for mobile devices.

How it works?

Gestate inserts a new HTML canvas element onto the page. The size and position of the normatively transparent canvas is altered to overlay another HTML element such as an image. Mouse and touch events are registered on the canvas elements. Particle effects are displayed on mouse/touch input in visualisation mode or when recording and playing back gestures. The visualisation is decoupled from (high frequency) input events, using requestAnimationFrame. Where the framerate is less than 60Hz, interpolation is used to avoid large gaps.

API example

Simple visualisation:

import { Gestate } from '@aikuma/gestate'
const gest = new Gestate({debug: true})
const ele = document.getElementById('image')
gest.visualise(ele)

To record gestures:

import { Gestate, Gesture } from '@aikuma/gestate'
let gestures: Gesture[] = []
const gest = new Gestate({debug: true})
const ele = document.getElementById('image')
gest.record(ele, 'attention', 0)
gest.stopRecording()
gestures = gest.getGestures()
gest.clear()

Constructor

const gest = new Gestate(config)

Optional config has three properties:

  • debug: boolean --- print debug information
  • colors: string[] --- array of RGB colours to use for visualisation in format #rrggbb.
  • element: HTMLElement to append canvas to. Defaults to document body.

On constructing Gestate will create a new canvas and attach mouse and touch pointer events.

methods

visualise()

Begin touch visualisation without recording gestures.

stopVisualise()

Stop visualisation.

record(element: HTMLElement, type: string, time: number)

Begin a recording session. element is a HTML element that will be used to obtain position information. The canvas will be resized and repositioned to fit this element. Typically the element would be an img tag, or a div with an image background.

The type arg is a string that describes what kind of recording this is. This is an arbitrary string that preserved in the data structure coming from getGestures()

The time arg is a number typically obtained from Date(). It's intended to represent a time offset. It can be optional and set to zero if desired.

stopRecord()

Stops recording. Any current gesture is finalised.

clearAll()

Clears all of the currently recorded gestures.

loadGestures(gestures: Gesture[])

Takes an array of Gesture objects. Typically this would be to play back previously recorded gestures.

playGestures(element: HTMLElement, time: number)

Begins playback of gestures from the given time point.

resize(element: HTMLElement)

Immediately resize and reposition the canvas to element.

stopPlay()

Stops playback of gestures.

getGestures()

Returns an array of Gesture objects.

destroy()

Removes the canvas element.

Gesture data structure

interface Gesture {
  timeOffset: number
  type?: string
  timeLine: {x: number, y: number, t: number}[]
}

A Gesture object has a timeOffset property representing the relative time of the gesture since the beginning of gesture recording. The type property is an arbitrary string describing the type of gesture. The timeLine is an array of objects with x and y numbers representing the current coordinates of the touch interaction.

Note that x and y coordinates range from values 0 to 1. The t number is a relative time offset in Milliseconds from the Gesture timeOffset value.

Compiling source

This is a Typescript project so just npm i to install the dependencies and then tsc -d to compile. Plain JavaScript is now in the dist folder, i.e. import { Gestate } from 'path/gestate/dist'.

To do

  1. Expose particle movement settings to allow tweaking the effect.

Changes

0.4.0 removed testing framework since I wasn't using it anyway. 0.4.2 add config option of .element for the html element the canvas will be appended to. 0.6.0 many bugs fixed, visualisation mode (without recording) added