@2players/dollar1-unistroke-recognizer 中文文档教程

发布于 6年前 浏览 23 项目主页 更新于 3年前

dollar1-unistroke-recognizer

$1 Unistroke 识别器版本代码风格:漂亮模块系统依赖状态Travis 构建状态NPM 下载

\$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()

License

麻省理工学院 © 2Players Studio

dollar1-unistroke-recognizer

$1 Unistroke Recognizer Versioncode style: prettierModule SystemDependency StatusTravis Build StatusNPM 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()

License

MIT © 2Players Studio

    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文