{"_id":"filtered-vector","_rev":"18-e1aad14162eed6f55c4622f5ca286e81","name":"filtered-vector","description":"Filter an input vector valued curve","dist-tags":{"latest":"1.2.5"},"versions":{"1.0.0":{"name":"filtered-vector","version":"1.0.0","description":"Filter an input vector valued curve","main":"fvec.js","directories":{"example":"example"},"dependencies":{"array-almost-equal":"^1.0.0","binary-search-bounds":"^1.0.0","cubic-hermite":"^1.0.0"},"devDependencies":{"almost-equal":"0.0.0","right-now":"^1.0.0","tape":"^3.5.0"},"scripts":{"test":"tape test/*.js"},"repository":{"type":"git","url":"https://github.com/mikolalysenko/filtered-vector.git"},"keywords":["filter","input","curve","device","mouse"],"author":{"name":"Mikola Lysenko"},"license":"MIT","bugs":{"url":"https://github.com/mikolalysenko/filtered-vector/issues"},"homepage":"https://github.com/mikolalysenko/filtered-vector","gitHead":"5b101ee72de1b6e6e7561f882dfcdd29e232a03d","_id":"filtered-vector@1.0.0","_shasum":"1f5eda5f1274f2f1c7b6a874ff16fa4a1a712c53","_from":".","_npmVersion":"2.1.4","_nodeVersion":"0.10.26","_npmUser":{"name":"mikolalysenko","email":"mikolalysenko@gmail.com"},"maintainers":[{"name":"mikolalysenko","email":"mikolalysenko@gmail.com"}],"dist":{"shasum":"1f5eda5f1274f2f1c7b6a874ff16fa4a1a712c53","tarball":"https://registry.npmjs.org/filtered-vector/-/filtered-vector-1.0.0.tgz","integrity":"sha512-ET9cao8relcmfmcXyZQhc9WF9xiuETzJSsScf63LIczp30EetQAA6cL+aJ2Iw01qi/UhZ+9BgfhXze0ZQ9sLgw==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIC9Jobzo4jr9LO9Ue6v7XqXJLGi+nLd6psQxpSVVVB/eAiAd57pJBUyJEWbCv6B/C/uLsyokLWAEBFDqrH2jSj91Sw=="}]}},"1.1.0":{"name":"filtered-vector","version":"1.1.0","description":"Filter an input vector valued curve","main":"fvec.js","directories":{"example":"example"},"dependencies":{"array-almost-equal":"^1.0.0","binary-search-bounds":"^1.0.0","cubic-hermite":"^1.0.0"},"devDependencies":{"almost-equal":"0.0.0","right-now":"^1.0.0","tape":"^3.5.0"},"scripts":{"test":"tape test/*.js"},"repository":{"type":"git","url":"https://github.com/mikolalysenko/filtered-vector.git"},"keywords":["filter","input","curve","device","mouse"],"author":{"name":"Mikola Lysenko"},"license":"MIT","bugs":{"url":"https://github.com/mikolalysenko/filtered-vector/issues"},"homepage":"https://github.com/mikolalysenko/filtered-vector","gitHead":"df4fa0652d03a19171af2ec0f9547ff24fc37824","_id":"filtered-vector@1.1.0","_shasum":"d3cf75e9a21cdcf8a84d4714cdbaff473bc977d0","_from":".","_npmVersion":"2.1.4","_nodeVersion":"0.10.26","_npmUser":{"name":"mikolalysenko","email":"mikolalysenko@gmail.com"},"maintainers":[{"name":"mikolalysenko","email":"mikolalysenko@gmail.com"}],"dist":{"shasum":"d3cf75e9a21cdcf8a84d4714cdbaff473bc977d0","tarball":"https://registry.npmjs.org/filtered-vector/-/filtered-vector-1.1.0.tgz","integrity":"sha512-abrDzzeuTWA2stfYh3vRMCbtUzD1jHTMAo/kkk1RYAKbpQahBFj1+1L8iG9kVfebEnQ3hkmAY+4sXMIaYIl+yA==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIBq3KaEUx6r/0J3jn6eqbR5kqQKPLnbO4cEmX3S/1sE2AiEA9DJnOpvFNtfNBGGi/DfkxcgYOUeRT6TMxNhPF2mPLdM="}]}},"1.2.0":{"name":"filtered-vector","version":"1.2.0","description":"Filter an input vector valued curve","main":"fvec.js","directories":{"example":"example"},"dependencies":{"binary-search-bounds":"^1.0.0","cubic-hermite":"^1.0.0"},"devDependencies":{"array-almost-equal":"^1.0.0","almost-equal":"0.0.0","right-now":"^1.0.0","tape":"^3.5.0"},"scripts":{"test":"tape test/*.js"},"repository":{"type":"git","url":"https://github.com/mikolalysenko/filtered-vector.git"},"keywords":["filter","input","curve","device","mouse"],"author":{"name":"Mikola Lysenko"},"license":"MIT","bugs":{"url":"https://github.com/mikolalysenko/filtered-vector/issues"},"homepage":"https://github.com/mikolalysenko/filtered-vector","gitHead":"010ad33b77b473ad7da2856abad8486200dab6f8","_id":"filtered-vector@1.2.0","_shasum":"4c1ac1dd2dd7061903bed9fd97b745ac88780433","_from":".","_npmVersion":"2.1.4","_nodeVersion":"0.10.26","_npmUser":{"name":"mikolalysenko","email":"mikolalysenko@gmail.com"},"maintainers":[{"name":"mikolalysenko","email":"mikolalysenko@gmail.com"}],"dist":{"shasum":"4c1ac1dd2dd7061903bed9fd97b745ac88780433","tarball":"https://registry.npmjs.org/filtered-vector/-/filtered-vector-1.2.0.tgz","integrity":"sha512-EoCvuaK9LeV3B0XgLHgFXv9g/qhfn+L0TrbVcfMBFn1VMZV5Cqk0ZL32QLa8BbLoQvXoxsRrO6P9mR8cDFcwJA==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDieV67BLZb/0LOCFvw7NzmK6hkEC09zHq6MZMpabN4IgIhAMxyLPCl6qwQLvS2Juj8zJ82h2DuP/q64fVuMSOVUIWQ"}]}},"1.2.1":{"name":"filtered-vector","version":"1.2.1","description":"Filter an input vector valued curve","main":"fvec.js","directories":{"example":"example"},"dependencies":{"binary-search-bounds":"^1.0.0","cubic-hermite":"^1.0.0"},"devDependencies":{"array-almost-equal":"^1.0.0","almost-equal":"0.0.0","right-now":"^1.0.0","tape":"^3.5.0"},"scripts":{"test":"tape test/*.js"},"repository":{"type":"git","url":"https://github.com/mikolalysenko/filtered-vector.git"},"keywords":["filter","input","curve","device","mouse"],"author":{"name":"Mikola Lysenko"},"license":"MIT","bugs":{"url":"https://github.com/mikolalysenko/filtered-vector/issues"},"homepage":"https://github.com/mikolalysenko/filtered-vector","gitHead":"5e18292c8a8391acee8ea97e26095ef03a42d43f","_id":"filtered-vector@1.2.1","_shasum":"9232adda95292f975d85656a5e339d230752b8df","_from":".","_npmVersion":"2.1.4","_nodeVersion":"0.10.26","_npmUser":{"name":"mikolalysenko","email":"mikolalysenko@gmail.com"},"maintainers":[{"name":"mikolalysenko","email":"mikolalysenko@gmail.com"}],"dist":{"shasum":"9232adda95292f975d85656a5e339d230752b8df","tarball":"https://registry.npmjs.org/filtered-vector/-/filtered-vector-1.2.1.tgz","integrity":"sha512-+3LVKvTOzd+uw/d1//FqIYMJ4eqKQY0KQwiHXmHJr1BWBMiwjUBNF+jJ5Sh7RFbgcVxeBiI2548yFj8cqB0ENg==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCICVOP8P17EPUhmNXjkkM6zhdr2a1SlwbCO+nfTxYd6yyAiEAj2xjOoxtpXtwri6AU75K6yUVhY7gHTLFfxnKzQbksuU="}]}},"1.2.2":{"name":"filtered-vector","version":"1.2.2","description":"Filter an input vector valued curve","main":"fvec.js","directories":{"example":"example"},"dependencies":{"binary-search-bounds":"^1.0.0","cubic-hermite":"^1.0.0"},"devDependencies":{"array-almost-equal":"^1.0.0","almost-equal":"0.0.0","right-now":"^1.0.0","tape":"^3.5.0"},"scripts":{"test":"tape test/*.js"},"repository":{"type":"git","url":"https://github.com/mikolalysenko/filtered-vector.git"},"keywords":["filter","input","curve","device","mouse"],"author":{"name":"Mikola Lysenko"},"license":"MIT","bugs":{"url":"https://github.com/mikolalysenko/filtered-vector/issues"},"homepage":"https://github.com/mikolalysenko/filtered-vector","gitHead":"3e7f9cc2a9d0ed14c44a75d4cfe3d17574b7e716","_id":"filtered-vector@1.2.2","_shasum":"e62b4c812adf9d370063433af29ed0ffe7df2f49","_from":".","_npmVersion":"2.1.4","_nodeVersion":"0.10.26","_npmUser":{"name":"mikolalysenko","email":"mikolalysenko@gmail.com"},"maintainers":[{"name":"mikolalysenko","email":"mikolalysenko@gmail.com"}],"dist":{"shasum":"e62b4c812adf9d370063433af29ed0ffe7df2f49","tarball":"https://registry.npmjs.org/filtered-vector/-/filtered-vector-1.2.2.tgz","integrity":"sha512-6SPu7elWwRQYHF8aWonjjPoXN3dR1L/vCOky6U8wiUeAtoID1NvPjHcfpm5Eou1m2uryrsAuuAY9WkRQpZLknA==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIH590TvM1a5LJO0hhpHdB+z5c5enDIBofcdndWH70uMNAiEAyGU4wF3Ki22/aE403yLGUEhI94/4wqQ/U/2UjmtirGk="}]}},"1.2.3":{"name":"filtered-vector","version":"1.2.3","description":"Filter an input vector valued curve","main":"fvec.js","directories":{"example":"example"},"dependencies":{"binary-search-bounds":"^1.0.0","cubic-hermite":"^1.0.0"},"devDependencies":{"array-almost-equal":"^1.0.0","almost-equal":"0.0.0","right-now":"^1.0.0","tape":"^3.5.0"},"scripts":{"test":"tape test/*.js"},"repository":{"type":"git","url":"https://github.com/mikolalysenko/filtered-vector.git"},"keywords":["filter","input","curve","device","mouse"],"author":{"name":"Mikola Lysenko"},"license":"MIT","bugs":{"url":"https://github.com/mikolalysenko/filtered-vector/issues"},"homepage":"https://github.com/mikolalysenko/filtered-vector","gitHead":"e660b9e2db58ef595cf4d9b8bddf7c9761b6e57d","_id":"filtered-vector@1.2.3","_shasum":"3bd8473c39f6c2a2b3b1c4f76c4115bc6f9803aa","_from":".","_npmVersion":"2.1.4","_nodeVersion":"0.10.26","_npmUser":{"name":"mikolalysenko","email":"mikolalysenko@gmail.com"},"maintainers":[{"name":"mikolalysenko","email":"mikolalysenko@gmail.com"}],"dist":{"shasum":"3bd8473c39f6c2a2b3b1c4f76c4115bc6f9803aa","tarball":"https://registry.npmjs.org/filtered-vector/-/filtered-vector-1.2.3.tgz","integrity":"sha512-IZkJvp+u0csOfrZeYvOm5tmzGeA0zZhtjUXfbHdPlbeRyVP6mdv9+40o8adnPBfN8bWvp2v4+xepA+90TZY7SQ==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIDUL9plhwaTlqHxbENAVA/yPbBzVYU9QPpeTaabu6nUUAiEA+wC7/F0WYRfX4lmyCw6U9+7+5LQtrN9kvPo65sOmXlo="}]}},"1.2.4":{"name":"filtered-vector","version":"1.2.4","description":"Filter an input vector valued curve","main":"fvec.js","directories":{"example":"example"},"dependencies":{"binary-search-bounds":"^1.0.0","cubic-hermite":"^1.0.0"},"devDependencies":{"array-almost-equal":"^1.0.0","almost-equal":"0.0.0","right-now":"^1.0.0","tape":"^3.5.0"},"scripts":{"test":"tape test/*.js"},"repository":{"type":"git","url":"https://github.com/mikolalysenko/filtered-vector.git"},"keywords":["filter","input","curve","device","mouse"],"author":{"name":"Mikola Lysenko"},"license":"MIT","bugs":{"url":"https://github.com/mikolalysenko/filtered-vector/issues"},"homepage":"https://github.com/mikolalysenko/filtered-vector","gitHead":"d80de2f8c8602491093c1e8f28560f78e54f4c0e","_id":"filtered-vector@1.2.4","_shasum":"56453c034df4302d293ca8ecdeac3f90abc678d3","_from":".","_npmVersion":"2.7.4","_nodeVersion":"0.12.2","_npmUser":{"name":"mikolalysenko","email":"mikolalysenko@gmail.com"},"dist":{"shasum":"56453c034df4302d293ca8ecdeac3f90abc678d3","tarball":"https://registry.npmjs.org/filtered-vector/-/filtered-vector-1.2.4.tgz","integrity":"sha512-vQ7o7nw0V0eHY1TdIvyjv86jrdUjM3Nt8DodmEhiHOrdg0C5o8wQJxNXmRI2yfM3rrHdJc1ziYs6zVvW6WZT+g==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCM2TWBbb9l92Gl+K7f3jdoTGx3FVWAnCOd11aPjtWuKgIhAL8HhmCQobt4gyGDXzqIbkFb4WjbWg9wyLJ/BnoYyg9r"}]},"maintainers":[{"name":"mikolalysenko","email":"mikolalysenko@gmail.com"}]},"1.2.5":{"name":"filtered-vector","version":"1.2.5","description":"Filter an input vector valued curve","main":"fvec.js","directories":{"example":"example"},"dependencies":{"binary-search-bounds":"^2.0.0","cubic-hermite":"^1.0.0"},"devDependencies":{"array-almost-equal":"^1.0.0","almost-equal":"0.0.0","right-now":"^1.0.0","tape":"^3.5.0"},"scripts":{"test":"tape test/*.js"},"repository":{"type":"git","url":"git+https://github.com/mikolalysenko/filtered-vector.git"},"keywords":["filter","input","curve","device","mouse"],"author":{"name":"Mikola Lysenko"},"license":"MIT","bugs":{"url":"https://github.com/mikolalysenko/filtered-vector/issues"},"homepage":"https://github.com/mikolalysenko/filtered-vector","gitHead":"d45c72a708cc7403560e9d9f4ba76d8d0fa97a8c","_id":"filtered-vector@1.2.5","_nodeVersion":"14.15.3","_npmVersion":"6.14.10","dist":{"integrity":"sha512-5Vu6wdtQJ1O2nRmz39dIr9m3hEDq1skYby5k1cJQdNWK4dMgvYcUEiA/9j7NcKfNZ5LGxn8w2LSLiigyH7pTAw==","shasum":"5a831278c159721dd3be34ef017842836ef3d461","tarball":"https://registry.npmjs.org/filtered-vector/-/filtered-vector-1.2.5.tgz","fileCount":6,"unpackedSize":14375,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJguEmlCRA9TVsSAnZWagAAOOUP/1XbKgGNjxbFfYJoLg+h\n8UuMZd9RAuKK8OlAlxy1mcXO2LZMfCZIqF1rsESL9iQ6O5lWj76rgxrxterc\nMgnJpdwpYYRXfeOL4tUd0KWdOZTGUWKZlJXG0rXvROV6RxZb9hX+pPVJbung\nB+BEVmGak3SRUBPw4LlfqfD91z9N3zDD56fi4kJSH9jv249pL+CbFkCkyGws\npyvwpkiM9+U7SjADiUl3HhErFklNLNuAfs42UAnmEXhVrjDKX/tQahUzq11t\nCzEVLf14IHuhXSSF9WaXV+Ll66aXD2gadQXT3bBhJmhfefU1kjCH9imQZ/zx\nVIFM5Ge6gz4iPBym2OoWsn4PUtHtwWLr4HHXOrlehdbyQmZ7xgXr9Qwu1DER\nRR7s3A+z3nlxlfNDW694Y78TFkJwhOSAvLSogVvR61yW1KJz0iNEiuMeqLmp\nz0yM7Bx9ubuaQgn832tqYSJpn9WlDXt7OzXklfywCJRyAXf+VIKYFlyGJcSi\nZCM3h7GQxBaBf4j1lJuImddog1mf8APzIjmsBAD4GhPR/K4KPWFZx+SnvnhD\ngYae+0NzPgKuCsPa+fFVaVuOMRzK/YLNgtZ9N9tTzPk3BAr8wjcIqNqtCvcA\nU/SfnnZ0mH7bQW/jvXVDXyc7F56KZkTx6edJ4hdNU2tEDb8qpJToxvR/YvQR\nwyP0\r\n=eay4\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIEi3JfFxIQzYjQId7FHVl9O6Ck3JXDPkRxzB4O3EqnxuAiEAjdPE+kFVYXnfH1HuBEjFoCqTr08jhp/CvX8HNiWqgN4="}]},"_npmUser":{"name":"mikolalysenko","email":"mikolalysenko@gmail.com"},"maintainers":[{"name":"mikolalysenko","email":"mikolalysenko@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/filtered-vector_1.2.5_1622690212952_0.9119561706065875"},"_hasShrinkwrap":false}},"readme":"filtered-vector\n===============\nApplies cubic smoothing to a vector valued curve.  This is useful for smoothing out inputs from the mouse or other input devices.\n\n# Example\n\n```javascript\nvar now = require('right-now')\nvar filterVector = require('filtered-vector')\nvar smoothPosition = filterVector([256, 256])\n\nvar canvas = document.createElement('canvas')\ncanvas.width = 512\ncanvas.height = 512\ndocument.body.appendChild(canvas)\nvar context = canvas.getContext('2d')\n\ncanvas.addEventListener('mousemove', function(ev) {\n  smoothPosition.push(now(), ev.x, ev.y)\n})\n\nfunction paint() {\n  requestAnimationFrame(paint)\n  var t = now()\n  context.fillStyle = 'rgba(0,0,0,1)'\n  context.fillRect(0,0,512,512)\n  \n  context.strokeStyle = '#0f0'\n  context.lineWidth = 1\n  context.beginPath()\n  var x = smoothPosition.curve(t)\n  context.moveTo(x[0], x[1])\n  for(var i=0; i<2000; ++i) {\n    var y = smoothPosition.curve(Math.floor(t - i))\n    context.lineTo(y[0], y[1])\n  }\n  context.stroke()\n}\npaint()\n```\n\n[Try out the demo in your browser.](https://mikolalysenko.github.io/filtered-vector)\n\n# Install\n\n```\nnpm i filtered-vector\n```\n\n# API\n\n## Constructor\n\n#### `var vec = require('filtered-vector')(initState[, initVelocity, initTime])`\nCreates a new smoothed vector with the given initial state, velocity and time.\n\n* `initState` is the initial state of the vector\n* `initVelocity` is the initial velocity of the vector\n* `initTime` is the initial time of the vector\n\n**Returns** A new smoothed vector valued curve\n\n## Methods\n\n#### `vec.curve(t)`\nComputes the value of the curve at time `t`\n\n* `t` is the time parameter to sample the curve\n\n**Returns** The value of the curve at time `t`\n\n#### `vec.dcurve(t)`\nComputes the derivative of the curve at time `t`\n\n* `t` is the time parameter\n\n**Returns** The derivative of the curve at time `t`\n\n#### `vec.bounds`\nA pair of arrays giving the upper and lower bounds on the constraints of the vector.  Default is `[-Infinity,-Infinity, ...]` and `[Infinity,Infinity,...]`\n\n#### `vec.push(t, ...)`\nAdds a new data point onto the end of the curve\n\n* `t` is the time the new data point was sampled\n* `...` are the components of the curve vector\n\n#### `vec.move(t, ...)`\nIncrementally moves the curve from the last sampled position by an offset.  This is useful with input devices that emit relative motion (for example scrolling, key press events, pointer lock)\n\n* `t` is the time at which the move event occured\n* `...` are the components of the relative motion\n\n#### `vec.set(t, ...)`\nSets the state of the curve at time `t`\n\n* `t` is the time parameter to sample\n* `...` are the components of the state\n\n#### `vec.jump(t, ...)`\nSets the state of the vector at time `t` with no smoothing.\n\n* `t` is the time parameter to sample\n* `...` are the components of the vector\n\n#### `vec.idle(t)`\nAdds a stationary data point to the curve (ie notify the curve that no input state has changed)\n\n* `t` is the time at which the curve was idle\n\n#### `vec.flush(t)`\nRemoves all samples in the buffer before time `t`\n\n* `t` is the cutoff time\n\n#### `vec.lastT()`\n\n**Returns** The time of the last sample in the curve\n\n#### `vec.stable()`\n\n**Returns** `true` is the vector is stationary as of the last event.\n\n# License\n(c) 2015 Mikola Lysenko.  MIT License","maintainers":[{"name":"mikolalysenko","email":"mikolalysenko@gmail.com"}],"time":{"modified":"2022-06-18T00:49:57.938Z","created":"2015-02-02T21:34:04.242Z","1.0.0":"2015-02-02T21:34:04.242Z","1.1.0":"2015-02-02T22:00:37.434Z","1.2.0":"2015-02-04T15:58:59.301Z","1.2.1":"2015-02-05T21:24:20.142Z","1.2.2":"2015-02-12T02:05:04.694Z","1.2.3":"2015-02-13T19:21:39.880Z","1.2.4":"2015-05-26T17:31:49.284Z","1.2.5":"2021-06-03T03:16:53.138Z"},"homepage":"https://github.com/mikolalysenko/filtered-vector","keywords":["filter","input","curve","device","mouse"],"repository":{"type":"git","url":"git+https://github.com/mikolalysenko/filtered-vector.git"},"author":{"name":"Mikola Lysenko"},"bugs":{"url":"https://github.com/mikolalysenko/filtered-vector/issues"},"license":"MIT","readmeFilename":"README.md","users":{"mreinstein":true}}