@2players/dollar1-unistroke-recognizer

A wrapper of $1 Unistroke Recognizer.

Usage no npm install needed!

<script type="module">
  import 2playersDollar1UnistrokeRecognizer from 'https://cdn.skypack.dev/@2players/dollar1-unistroke-recognizer';
</script>

README

dollar1-unistroke-recognizer

$1 Unistroke Recognizer Version code style: prettier Module System Dependency Status Travis Build Status NPM Downloads

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