{"name":"poem-loop","version":"1.0.4","description":"A requestAnimationFrame loop for visualizations, demos, experiments, art, and poems.","main":"lib/loop.js","scripts":{"test":"echo \"Error: no test specified\" && exit 1"},"repository":{"type":"git","url":"https://github.com/tatumcreative/poem-loop/"},"keywords":["programming-poem","visualization","game","art","loop","requestAnimationFrame","game loop"],"author":{"name":"Greg Tatum"},"license":"MIT","dependencies":{"events":"^1.0.2","lodash":"^2.4.1","raf":"^2.0.4"},"gitHead":"56cece7be263addcbf4765e2041eb56ec97a8781","_id":"poem-loop@1.0.4","_shasum":"f565be29787becf2e44c3445b61cf0ca9718b3ba","_from":".","_npmVersion":"2.1.17","_nodeVersion":"0.10.35","_npmUser":{"name":"tatumcreative","email":"tatum.creative@gmail.com"},"maintainers":[{"name":"tatumcreative","email":"tatum.creative@gmail.com"}],"dist":{"shasum":"f565be29787becf2e44c3445b61cf0ca9718b3ba","tarball":"http://registry-npm.ywwl.com/poem-loop/download/poem-loop-1.0.4.tgz","integrity":"sha512-VGgNy4t+QmZHzGCu44QbvHEoMePM5bgnhwoG/ywoi+9TYnXgCb1pvkWnzNDG4WfjN1daD283LkAtkqGM6stDYw==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDxL9nCwo73BRNGUjwheCfzl//FzbzAsP1EuUo9uRSQ8gIgT2AR9onNnh9EUZ2XSu+HEkDEXks0iO0cIQ98ZCyxIAE="}],"size":2892,"noattachment":false,"key":"/poem-loop/-/poem-loop-1.0.4.tgz"},"directories":{},"readme":"# poem-loop\n\nThis module is a configurable event loop for visualizations, demos, experiments, art, and poems. It provides an `update` and `draw` event, as well as `updatedone` and `drawdone`. It uses the [raf](https://www.npmjs.com/package/raf) module for the requestAnimationFrame.\n\nPart of the [programming-poem](https://www.npmjs.com/browse/keyword/programming-poem) module series.\n\n## Usage\n\nIts primary intended use is with [Browserify](http://browserify.org/).\n\nFrom the command line:\n\n\tnpm install poem-loop --save\n\nThen in your code:\n\n\tvar loop = require('poem-loop')( configuration );\n\t\n\tloop.start();\n\t\n\tloop.emitter.on('update', function( e ) {\n\t\tbox.position.x += e.dt;\n\t\tgameClock.text( e.elapsed );\n\t});\n\t\n\tloop.emitter.on('draw', function( e ) {\n\t\trenderer.render();\n\t});\n\t\n## Event object\n\nThe event object has the following values.\n\n * `dt` - The change in time in milliseconds.\n * `unitDt` - The change in time as a unit interval (0-1). Assumes 1 is equal to 16.6666 milliseconds.\n * `now` - The current Date.now() in milliseconds.\n * `elapsed` - The elapsed game time in milliseconds, starts at 0. Does not increment when the loop is stopped.\n\n## Configuration\n\nThe loop can be configured.\n\n\tvar loop = require('poem-loop')({\n\t\temitter: poemEmitter,\n\t\tcustomizeEvent : function( event ) {\n\t\t\tevent.mousePosition = getMousePosition();\n\t\t\treturn event;\n\t\t}\n\t});\n\n#### `emitter`\n\nA node.js EventEmitter. If one is set, it is used by the loop. Otherwise a new EventEmitter is created.\n\n#### `customizeEvent`\n\nA function that customizes the event object that is passed to the update and draw event. It gets passed the object and should return the object.\n\n## Interface\n\n#### `loop.start()`\n\nStart the loop.\n\n#### `loop.stop()`\n\nStops the loop but doesn't reset the elapsed time.\n\n#### `loop.reset()`\n\nResets the elapsed time.\n\n#### `loop.emitter`\n\nThe event emitter.","publish_time":1423548245245,"_cnpm_publish_time":1423548245245,"dist-tags":{"latest":"1.1.1"}}