@2players/dollar1-unistroke-recognizer
v0.3.1
Published
A wrapper of $1 Unistroke Recognizer.
Downloads
11
Readme
dollar1-unistroke-recognizer
A wrapper of $1 Unistroke Recognizer.
Install
$ npm install @2players/dollar1-unistroke-recognizer
Usage
import GestureRecognizer from '@2players/dollar1-unistroke-recognizer'
// create recognizer with default strokes
const gr = new GestureRecognizer()
// create recognizer without default strokes
const gr = new GestureRecognizer({ defaultStrokes: false })
/**
* recognize gestures
*/
const stroke = [
{ x: 310, y: 230 },
{ x: 333, y: 186 },
{ x: 356, y: 215 },
{ x: 375, y: 186 },
{ x: 399, y: 216 },
{ x: 418, y: 186 },
]
gr.recognize(stroke, true)
// 'zig-zag'
/**
* add custom gesture
*
* If you don't know how to get enough points, you can try following app:
*
* https://2players.github.io/unistroke-creator/
*/
const customStroke = [
{ x: 0, y: 0 },
// ... more points
]
gr.add('a-name', customStroke)
/**
* reset gestures
*
* Remove all customized gestures.
*/
gr.reset()
Related
License
MIT © 2Players Studio