{
  "name": "@workshop/compare",
  "version": "1.0.0",
  "dependencies": {},
  "readme": "# @workshop/compare\n\nCompares two `init`/`draw` pairs on an offscreen 200*200 canvas. The canvas is\ninstrumented with `gl-reset` in order to prevent state from leaking out and\nminimise the risk of memory leaks.\n\nReturns a value between 0 and 1, where 1 is a complete match and 0 is a\ncomplete failure.\n\nAccepts the following options:\n\n## opts.threshold\n\nThe maximum difference between two pixels before they're\nconsidered to no longer be matching. This is the *total* difference between\nthe red, green, and blue channels and as such can range between 0 and 765.\n\n## opts.init\n\nPass in a custom hook for handling the `init` function of each\nsubmission/solution.\n\n``` javascript\ninit: function(gl, initFn) {\n  return initFn.call(gl, gl, imgElement)\n}\n```\n\n## opts.draw\n\nPass in a custom hook for handling the `draw` function of each\nsubmission/solution.\n\n``` javascript\ndraw: function(gl, drawFn) {\n  return drawFn.call(gl, gl, Date.now())\n}\n```\n\n## Example\n\nPseudocode for checking an exercise at 10 random intervals over a period of\n5 seconds:\n\n``` javascript\nvar times  = [Date.now()]\nvar passed = true\n\nfor (var i = 0; i < 9; i++) {\n  times.push(times[0] + Math.random() * 5000)\n}\n\nfor (var i = 0; i < times.length; i++) {\n  passed = passed && compare(submission, solution, {\n      threshold: 5\n    , draw: function(gl, drawFn) {\n      return drawFn.call(gl, gl, times[i])\n    }\n  })\n}\n\ndone(null, passed)\n```\n",
  "readmeFilename": "README.md",
  "description": "Compares two `init`/`draw` pairs on an offscreen 200*200 canvas. The canvas is instrumented with `gl-reset` in order to prevent state from leaking out and minimise the risk of memory leaks.",
  "_id": "@workshop/compare@1.0.0",
  "scripts": {},
  "_shasum": "d0a612a0af79deb553963d9eebe7c3ae83cc5cd7",
  "_from": "workshop/compare",
  "_resolved": "file:workshop/compare"
}
