2.1.0 • Published 8 years ago

one-dollar v2.1.0

Weekly downloads
5
License
ISC
Repository
-
Last release
8 years ago

$1 for Node/browserify

This is a simple wrapper around shape detector library $1 (1dollar.js).

Install

npm install one-dollar

Usage

Verbose (original API)

const OneDollar = require('one-dollar')

const recognizer = new OneDollar.DollarRecognizer()

const result = recognizer.Recognize([
  new Recognizer.Point(1, 2),
  new Recognizer.Point(10, 3),
  new Recognizer.Point(12, 27),
  new Recognizer.Point(3, 25),
  new Recognizer.Point(0, 0)
])

console.log(result)
// Result { Name: 'caret', Score: 0.7524355578423304 }

Shorter API

Original API is quite weird : force using new Points, title-cased methods… and it's way too verbose.

This module proposes a shortcut for faster access to what you want:

const OneDollar = require('one-dollar')

const recognize = OneDollar()

const result = recognize([[1, 2], [10, 3], [12, 27], [3, 25], [0, 0]])

console.log(result)
// Result { name: 'caret', score: 0.7524355578423304 }

Differences from original API:

  • no new OneDollar.DollarRecognizer, the function returns directly a recognition function
    • This function accepts [x, y] instead of new OneDollar.Point(x, y) (you can still instanciate points, if you really want)
    • This function returns object with lower-cased properties ({name, score} instead of {Name, Score})
    • In case of no match, the result's name is nomatch instead of No match.
  • you still have access to original methods, but they're camelcased:
    • recognize.recognize instead of recognizer.Recognize
    • recognize.addGesture instead of recognizer.AddGesture
    • recognize.deleteUserGestures instead of recognizer.DeleteUserGestures
    • recognize.gestures instead of recognizer.Unistrokes to list user gestures
    • Note that those methods are the original ones, and will require Point instances
2.1.0

8 years ago

2.0.0

8 years ago

1.0.0

8 years ago