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

shape-detector

v0.2.1

Published

Shape/gesture/stroke detection/recognition algorithm based on the $1 (dollar) Recognizer

Downloads

13

Readme

Shape Detector

Shape/gesture/stroke detection/recognition algorithm based on the $1 (dollar) Recognizer

Shape Detector is a refactored version of the $1 (dollar) Recognizer without the protractor and with a few other tweaks. It's available as a module which can be used client side and with Node.js.

Usage

Install using bower: bower install shape-detector
Or using npm: npm install shape-detector
Or just by downloading the tarball


	var detector = new ShapeDetector(ShapeDetector.defaultShapes)
	var stroke = [{ x: 127, y: 141 }, { x: 124, y: 140 }, { x: 120, y: 139 }, { x: 118, y: 139 }, { x: 116, y: 139 }, { x: 111, y: 140 }, { x: 109, y: 141 }, { x: 104, y: 144 }, { x: 100, y: 147 }, { x: 96, y: 152 }, { x: 93, y: 157 }, { x: 90, y: 163 }, { x: 87, y: 169 }, { x: 85, y: 175 }, { x: 83, y: 181 }, { x: 82, y: 190 }, { x: 82, y: 195 }, { x: 83, y: 200 }, { x: 84, y: 205 }, { x: 88, y: 213 }, { x: 91, y: 216 }, { x: 96, y: 219 }, { x: 103, y: 222 }, { x: 108, y: 224 }, { x: 111, y: 224 }, { x: 120, y: 224 }, { x: 133, y: 223 }, { x: 142, y: 222 }, { x: 152, y: 218 }, { x: 160, y: 214 }, { x: 167, y: 210 }, { x: 173, y: 204 }, { x: 178, y: 198 }, { x: 179, y: 196 }, { x: 182, y: 188 }, { x: 182, y: 177 }, { x: 178, y: 167 }, { x: 170, y: 150 }, { x: 163, y: 138 }, { x: 152, y: 130 }, { x: 143, y: 129 }, { x: 140, y: 131 }, { x: 129, y: 136 }, { x: 126, y: 139 }]
	detector.spot(stroke) // returns circle

	// You can also specify what you're looking for
	detector.spot(stroke, 'triangle') // returns null as the circle doesn't match the triangle

	// The detector can also learn new shapes
	stroke = [{ x: 307, y: 216 }, { x: 333, y: 186 }, { x: 356, y: 215 }, { x: 375, y: 186 }, { x: 399, y: 216 }, { x: 418, y: 186 }]
	detector.learn('zig-zag', stroke)

	// Name lookup is done with indexOf so you can make "groups" of shapes
	detector.lean('zig-zag 2', stroke)

	detector.spot(stroke, 'zig-zag') // will look for both circle and circle 2 and return the closest

	// ShapeDetector can also take options
	// nbSamplePoints is 64 by default and potentially improves accuracy
	// threshold by default is 0, a higher number will be less forgiving of wonky shapes
	detector = ShapeDetector(ShapeDetector.defaultShapes, { nbSamplePoints: 128, threshold: 0.8 })

TODO

  • Testing
  • Integrate $P

Changelog

  • 0.2.1 - Improve default shapes
  • 0.2.0 - First release