{"_id":"@campionfellin/node-p5","_rev":"4-cfb0324a68c302deabab13ec54e4583e","name":"@campionfellin/node-p5","dist-tags":{"latest":"1.0.6"},"versions":{"1.0.3":{"name":"@campionfellin/node-p5","version":"1.0.3","description":"A Node.js port of the p5.js library","main":"index.js","dependencies":{"axios":"^0.21.1","canvas":"^2.5.0","gifencoder":"^2.0.1","is-url":"^1.2.4","jimp":"^0.16.1","jsdom":"^16.5.3","png-file-stream":"^1.2.1"},"scripts":{"test":"echo \"Error: no test specified\" && exit 1"},"repository":{"type":"git","url":"git+https://github.com/andithemudkip/p5-node.git"},"keywords":["p5","p5js","image","animation"],"author":{"name":"AndiTheMudkip"},"license":"GNU LESSER GENERAL PUBLIC LICENSE","bugs":{"url":"https://github.com/andithemudkip/p5-node/issues"},"homepage":"https://github.com/andithemudkip/p5-node#readme","gitHead":"0f1d7ee5f76bf190ee6b0afb493883532bf7fd84","_id":"@campionfellin/node-p5@1.0.3","_nodeVersion":"14.5.0","_npmVersion":"6.14.5","dist":{"integrity":"sha512-IYEt/B105UYulY78+zfnOJZozuc6TKmicQgnf8mVNPzlMEz8QYMjRc4NmgtwGJ/+tWZjxHw7LwfiWZAYRjO8pg==","shasum":"9a98f24eae990122a3fb4cb125dc268b420cd6d2","tarball":"https://registry.npmjs.org/@campionfellin/node-p5/-/node-p5-1.0.3.tgz","fileCount":4,"unpackedSize":1074331,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgfbIxCRA9TVsSAnZWagAAQIgP/1xVE/Bt6qW4D4iMLsIC\nx6QMxT53v7v4qXs6ZouGSKfb3nUVVRN5zL52IYwGo3634ppVVSKOKzuqpsre\nR+frHYaOEVMoR6IHia/IkInxNS/dsRFvIuvMtlxw7hYpjgUIfz7FTlycQ9e4\nASelxXqDY+4Co7S5+KpbWeoedmBPCRnxoLmemoBq6RWebpib5RsjkXOBoXjb\ndm0xI/1EHrvsYFmv9ELIhOWEBPmTLMjXjG6wQpiXwwORIIGkdxz4kJsun95P\n6v93qWqBUUfTEKhMRC3xXsH+4akWN8oVQ4dDSqAsgUwltGOp9JDQ5XWf4JK3\nhfNnXJ+vK8d/nG9McrlxpqS9Ffx1IYwSQubMJ7ScnZTTVDru7ScrNcE7XKxu\no9OX4lYnGZ8U3buMtKqxi6tY4Kl9mu75CHsEixw5thpo4hI1tR5yOj3T9Wp4\nqVp3FAQ7m4yGzGdKoRXSBdM9tlHtyOHLdc+cuR1mmoiwJFNk5lEwD8d5nLKl\nLp2VrKZ0eSHUSZMh342c7PsTaOD4LdNvZ1tiXWIjMRibekxF5vDqVs3BW8+9\n7B5u3hQuSdsiO7ErZUyDgKKWs6mhTU4NHumvELcG9K9lwxTJ7QUpnJLPZP6K\nrJocO+IVEFykd40rYVrtaK4uIY/Ueu9eL8SGWIpMY6hnxG2w/FGDPQaDDNuI\nOiUl\r\n=5a/m\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCCFSpdEOsXCBL4a4LaWU98QisI/bAtPnZ2DU7gWvkVtwIgeyjTfDDnDYgthEagqMNgM8N5UGshD3qnMZ8Zbjh7dMo="}]},"_npmUser":{"name":"campionfellin","email":"campionfellin@gmail.com"},"directories":{},"maintainers":[{"name":"campionfellin","email":"campionfellin@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/node-p5_1.0.3_1618850353043_0.1728594188678323"},"_hasShrinkwrap":false},"1.0.4":{"name":"@campionfellin/node-p5","version":"1.0.4","description":"A Node.js port of the p5.js library","main":"index.js","dependencies":{"axios":"^0.21.1","canvas":"^2.5.0","gifencoder":"^2.0.1","is-url":"^1.2.4","jimp":"^0.16.1","jsdom":"^16.5.3","png-file-stream":"^1.2.1"},"scripts":{"test":"echo \"Error: no test specified\" && exit 1"},"repository":{"type":"git","url":"git+https://github.com/andithemudkip/p5-node.git"},"keywords":["p5","p5js","image","animation"],"author":{"name":"AndiTheMudkip"},"license":"GNU LESSER GENERAL PUBLIC LICENSE","bugs":{"url":"https://github.com/andithemudkip/p5-node/issues"},"homepage":"https://github.com/andithemudkip/p5-node#readme","gitHead":"8aee1c52e40db761096b73d1eb560e75ee371b5c","_id":"@campionfellin/node-p5@1.0.4","_nodeVersion":"14.5.0","_npmVersion":"6.14.5","dist":{"integrity":"sha512-eWxmFgqRSvsJF2kFyPxwDoQkLxtB3M75EiTdkwEf16GId/yuKJlFMxDUaGO0wNPt3HBUkG27Mk9HVVYnjGzXFw==","shasum":"a1a1a2a61010f94b6f179655fbcbd263d5ede2ed","tarball":"https://registry.npmjs.org/@campionfellin/node-p5/-/node-p5-1.0.4.tgz","fileCount":4,"unpackedSize":1074341,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgfbQpCRA9TVsSAnZWagAAxtAP/Rh2F4a6Qh1FCcOa8KdC\n1JQT5lZMIxecfORvQmQJD8rmsPgLehK/nsFnpviL4NZmi9p82L6pTIte4U4N\nGw1V6pWMeoqhi6cig9yK5pQCeSVllw+TKQ3VXjiDjEqXfA1pu+bkbTiA8HDW\nRU9ia9PUpclDqr9u3qmNb44BEeg8mSzLa9X+UKXd0ec3rZm3MW2OHrjG18Vh\nYWGg3CZVWOsCWC1UhogzaDhxAWeZ08+tutgM6xXxYLM/htzg50hiyspHOrql\nFVaKgof73cnQzSEREgW8tvKSibEnilPLyww28BVcpY2GT57f6+UusmAY9rQh\nclr69si5J3H7bDjC8oSjuxCIwjKT0JcvPiiKdAVLMiNOKqc5rjgt8w8Gnx+J\n/qgdVYkRJEMbjmzyEI9r9mYQoenEd9+i8CnIOy98ZVnz/Zu6tL8sDiOa84ys\n+7hhMPIzLH2ePaq1eVP6YbXugIHCoxxKy2wH4zBF9/W4RAFZeolw9yguDEG6\n7zPg6kEpc0fkV20PDFMCkoysWdLXhcV5AyahpYOQfYg3qvGKcbt3sa1WFATM\njWAa35QbNzjmfM4VSUIBBXaPfsgN/ZeAf54LF/9enBE5tyIgowr5vubtCuCa\nizgGYol/PmgasxUzYgInkGYfPEqpFBTNU7DDFR6zWnYFni4VGh30azZCsZ5s\nt14J\r\n=5xUO\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIFvK7h5g7Ecm8Zl5YqWVuiU2TYvECx5mhnfBRAAWjXaFAiBU7KP8TNAcqLC3ZB4D6ZQQVWj5gMD8bxTbm6S7/SAfFw=="}]},"_npmUser":{"name":"campionfellin","email":"campionfellin@gmail.com"},"directories":{},"maintainers":[{"name":"campionfellin","email":"campionfellin@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/node-p5_1.0.4_1618850856683_0.08102504419707812"},"_hasShrinkwrap":false},"1.0.5":{"name":"@campionfellin/node-p5","version":"1.0.5","description":"A Node.js port of the p5.js library","main":"index.js","dependencies":{"axios":"^0.21.1","canvas":"^2.5.0","gifencoder":"^2.0.1","is-url":"^1.2.4","jimp":"^0.16.1","jsdom":"^16.5.3","png-file-stream":"^1.2.1"},"scripts":{"test":"echo \"Error: no test specified\" && exit 1"},"repository":{"type":"git","url":"git+https://github.com/andithemudkip/p5-node.git"},"keywords":["p5","p5js","image","animation"],"author":{"name":"AndiTheMudkip"},"license":"GNU LESSER GENERAL PUBLIC LICENSE","bugs":{"url":"https://github.com/andithemudkip/p5-node/issues"},"homepage":"https://github.com/andithemudkip/p5-node#readme","gitHead":"36de3496a9d269875aa699491e47bed3ba5298b6","_id":"@campionfellin/node-p5@1.0.5","_nodeVersion":"14.5.0","_npmVersion":"6.14.5","dist":{"integrity":"sha512-Sx2cpDmKTqv9ErBHzJmYCYKsVX0Z1sZzx5F6aqhFZ4RsUIcA/THIjIESvFtpGp2EvD3QxBLjmnO/172SI1pStA==","shasum":"4b14f74ee3ea4c2e6c2e1d82b49ce63d8e92239e","tarball":"https://registry.npmjs.org/@campionfellin/node-p5/-/node-p5-1.0.5.tgz","fileCount":4,"unpackedSize":1074307,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgfbSeCRA9TVsSAnZWagAAXawQAKFjwO2VlARqlOvwDMLm\nd95Gxo2/QwmcI2LHWcGOojtXeiCSCS70y0oLR7Yu55PpzjfSmSTzNdtkA8TS\n4Sn76acFDHVAJ1mGtsxyxYO7Qrm+Hmey4/P7mHBxO1nu+llUr1OKcPrvCdeR\nhdfi0lp/sLlSjqcye4/rnwndmWEq1/3esSl3z3UQR6NjE4qmohqxolaK0zTt\nK3HmGsNEOg50HMkHp5xfE7SLt8lvtolCjrr7YXlRYL1W8ph367DWAcgPTUnI\n43C6kzNMy0l6owOjyHisd59j8PalOcrXIU74zXgVgREfqDmZTtEPk+AkrA56\neFgRqGBlQyeKmpeZFZJmGT6imXu+aWhcAbdDFKxBUBYsRQd03EiElmNIqcJm\nDyA1gtwZ7crv4CLTDpbAwH8E98mCxDBOTU5IacSys93/lUbRpj1Enez7Ydei\ncxcsLWQZ1HvdjSTOTScxRVDHRFIVdXDTjZ8XKujAbxJLV2WnqLjm89/my0U6\n8CEGEDu6rvEoqvmpTY+/jaFFb7QR5pHFih8E7VTK894UT7/n2/wVAVwFt4D0\nAmiEk25bgDBmyqcjjZd560EDpxspSJEKBlloT3xg9G/4gYVRZ+d4yEjEAJPj\nk/EpejHAZDkGU2e/DAmY0sknNXw05kAHaU1qDgl+iiNA9Ho57x5i9UzixLpj\nu7pi\r\n=9OzZ\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDj+e1LBrMRytbrMu26Jb1PtcLX9ud1KRZr6GoR9rAnQgIhAJP+tu9BlYOhhCO0o8tnmzkJvY/AEHfaVQJLzzNSKRDA"}]},"_npmUser":{"name":"campionfellin","email":"campionfellin@gmail.com"},"directories":{},"maintainers":[{"name":"campionfellin","email":"campionfellin@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/node-p5_1.0.5_1618850973474_0.9820934967539146"},"_hasShrinkwrap":false},"1.0.6":{"name":"@campionfellin/node-p5","version":"1.0.6","description":"A Node.js port of the p5.js library","main":"index.es6","dependencies":{"axios":"^0.21.1","canvas":"^2.5.0","gifencoder":"^2.0.1","is-url":"^1.2.4","jimp":"^0.16.1","jsdom":"^16.5.3","png-file-stream":"^1.2.1"},"scripts":{"test":"echo \"Error: no test specified\" && exit 1"},"repository":{"type":"git","url":"git+https://github.com/andithemudkip/p5-node.git"},"keywords":["p5","p5js","image","animation"],"author":{"name":"AndiTheMudkip"},"license":"GNU LESSER GENERAL PUBLIC LICENSE","bugs":{"url":"https://github.com/andithemudkip/p5-node/issues"},"homepage":"https://github.com/andithemudkip/p5-node#readme","gitHead":"36de3496a9d269875aa699491e47bed3ba5298b6","_id":"@campionfellin/node-p5@1.0.6","_nodeVersion":"14.5.0","_npmVersion":"6.14.5","dist":{"integrity":"sha512-aS1082CManCpUu9J8YfXbFCZx4D76fY4Lfr6gGs7vgyrY6wLSrWgwKs6AHNwcjHjAy0WPexueLjTiW0eTP8yVg==","shasum":"dd33b219ad8d4d3f937623d71ad78e7c821f959a","tarball":"https://registry.npmjs.org/@campionfellin/node-p5/-/node-p5-1.0.6.tgz","fileCount":4,"unpackedSize":1074308,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgfdK+CRA9TVsSAnZWagAA11IP/i8nvAi55Fz44nr24D19\nJU0bxNkKH8AR/Mfb324bUZXDQbdeiVjW3QXop5DMLYsbmf6tw5J6K69khrzs\n/9dwHUSVLVZEeqhEC6jfdx1DiM9dK44X64ipZ0KYyDSbHz6aiSfkhEm0z4ES\nWk1ByiOLluZ/k9z21hxV0E8avyiwFjdSgZbXC4akaaekMQQIw/6hMPfmZB1u\nJxU9rbxJcmfwQQewhV8HBfuDEUgDU0lhXoYW2eDBiahI7OoVC7yV1SBgSqA/\nqR+xi+WHNtoFeUofLpEdw8c6NcLX9cdZDJaHWGNk0a29dyo113wxGMpliVje\nHU4iisa0FhxCKIVQsIEjwkbZfglofD/AQJLuPeUZmZsBqH3bMfp7b39xeul0\nDdkVnd2hOdWmrSJYIO3ZB8vsXKomaI9U4+9lfOkQrNAlfgx/WPkLkyi+YZqP\ndDPlyQOtnaxErdgYSRbFNMXx/6emMonGfsGhhyJHejMEHmY2rtqY1PLbvj6/\nvBBdbSb+C8eg9S9KkhJWqmnmqz6WAQGo4YZCarG/+vTY1kU6tYF7JJTxQoyP\nJ59WPiLorm4KchW6hVgoxi2Yn0qrdNJ0fM9bYGfXjNjnMsgFbM14lUEsNfQj\n92ADLR5xmiEHVH+f7xqn2t2s/18/bhN8iMoC96W9S+Gae6D8efOuWs3GofqV\ne+mt\r\n=zKyH\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCo52WD1MEdfw6pFaqa/X8K6Zbi+BcFCfTg79RBmjv/4QIhANWyZ7hjiX6XyrKSuRJrRm+NEGJy2XU4wKIJWrFJC393"}]},"_npmUser":{"name":"campionfellin","email":"campionfellin@gmail.com"},"directories":{},"maintainers":[{"name":"campionfellin","email":"campionfellin@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/node-p5_1.0.6_1618858685937_0.6697337109233668"},"_hasShrinkwrap":false}},"time":{"created":"2021-04-19T16:39:12.993Z","1.0.3":"2021-04-19T16:39:13.199Z","modified":"2022-04-04T21:34:57.459Z","1.0.4":"2021-04-19T16:47:36.870Z","1.0.5":"2021-04-19T16:49:33.669Z","1.0.6":"2021-04-19T18:58:06.142Z"},"maintainers":[{"name":"campionfellin","email":"campionfellin@gmail.com"}],"description":"A Node.js port of the p5.js library","homepage":"https://github.com/andithemudkip/p5-node#readme","keywords":["p5","p5js","image","animation"],"repository":{"type":"git","url":"git+https://github.com/andithemudkip/p5-node.git"},"author":{"name":"AndiTheMudkip"},"bugs":{"url":"https://github.com/andithemudkip/p5-node/issues"},"license":"GNU LESSER GENERAL PUBLIC LICENSE","readme":"# node-p5\n\n### What is this?\n\nA Node.js implementation of the [p5.js][p5js] library.\n(using `node-canvas` and `jsdom`, along with a bunch of other modules)\n\n### FAQ\n\nWhy?\n\n> yes\n\nDoes everything from p5 work?\n\n> most things work, except for stuff like 3D (webgl is not a thing in node), interacting with the canvas (mouse, keyboard, window events) - because, duh, there's no window, and certain things that i didn't feel like implementing because there are a bunch of better alternatives for Node (like httpDo, httpGet, and httpPost can be easily replaced by just using `request` or `axios`)\n\nIs the syntax the same?\n\n> for most things, yes - you can find the docs below for the features that are different from the official p5 browser library\n\n## Installing\n\n```shell\n$ npm i --s node-p5\n```\n\n## Getting Started\n\nAll p5 methods must be preceded by the variable you pass to the sketch function.\n\n```js\nconst p5 = require('node-p5');\n\nfunction sketch(p) {\n    p.setup = () => {\n        p.createCanvas(200, 200);\n    }\n    p.draw = () => {\n        p.background(50);\n        p.text('hello world!', 50, 100);\n    }\n}\n\nlet p5Instance = p5.createSketch(sketch);\n\n```\n\nOf course, we can't see this because there is no window, so we should save the canvas as an image.\n\n```js\nconst p5 = require('node-p5');\n\nfunction sketch(p) {\n    p.setup = () => {\n        let canvas = p.createCanvas(200, 200);\n        setTimeout(() => {\n            p.saveCanvas(canvas, 'myCanvas', 'png').then(filename => {\n                console.log(`saved the canvas as ${filename}`);\n            });\n        }, 100);\n    }\n    p.draw = () => {\n        p.background(50);\n        p.text('hello world!', 50, 100);\n    }\n}\n\nlet p5Instance = p5.createSketch(sketch);\n```\n\n## Preloading\n\nI couldn't get the p5 preload to work. I wrote my own version.\n\n#### Basic usage\n\nYou can pass the [built-in preload functions](#built-in-preload-functions)\n\n```js\nconst p5 = require('node-p5');\n\nlet resourcesToPreload = {\n    catImage: p5.loadImage('cat.png')\n}\n\nfunction sketch(p, preloaded) {\n    let catImg = preloaded.catImage;\n    p.setup = () => {\n        let canvas = p.createCanvas(100, 100);\n        p.image(catImg, 20, 20, 60, 60);\n        \n        p.saveCanvas(canvas, 'out', 'png').then(() => {\n            console.log('saved canvas as out.png');\n        }).catch(console.error)\n\n        p.noLoop();\n    }\n}\n\nlet p5Instance = p5.createSketch(sketch, resourcesToPreload);\n```\n\nor you can pass in your own functions (both sync and async work!)\n\n```js\nlet resourcesToPreload = {\n    myVar: () => {\n        return 5+2;\n    },\n    myVar2: () => {\n        return new Promise((resolve, reject) => {\n            setTimeout(() => {\n                resolve('thing');\n            }, 500);\n        });\n    },\n    myVar3: new Promise((resolve, reject) => {\n        setTimeout(() => {\n            resolve('thing');\n        }, 500);\n    })\n}\n```\n\n## Fonts\n\n### !! make sure you load fonts before creating the sketch !!\n\n> \"Why can I not use `loadFont` in preload?\" - you might ask\n>\n> > and the answer to that is: because I couldn't get it to work lmao\n\nLoading custom fonts can be done using the `loadFont` method\n\n```js\np5.loadFont({ path: String, family: String})\n//or\np5.loadFont(filename: String)\n```\n\nexample:\n\n```js\nconst p5 = require('node-p5');\n\nlet sugarpunch;\nsugarpunch = p5.loadFont({ path: 'SugarpunchDEMO.otf', family: 'Sugarpunch' });\n//OR\nsugarpunch = p5.loadFont('SugarpunchDEMO.otf');\n\nfunction sketch(p) {\n    p.setup = () => {\n        let canvas = p.createCanvas(100, 100);\n        p.textFont(sugarpunch); // or p.textFont('Sugarpunch')\n        p.text('some text using the font', 20, 20);\n        \n        p.saveCanvas(canvas, 'out', 'png').then(f => {\n            console.log(`saved canvas as ${f}`);\n        }).catch(console.error)\n\n        p.noLoop();\n    }\n}\n\nlet p5Instance = p5.createSketch(sketch);\n\n```\n\n\n\n## Built-in preload functions\n\nnote: when passed as preload functions to p5.createSketch you shouldn't use the callback; otherwise, if you're using them inside your sketch you can either use the callback or `.then` as they return promises.\n\nnote2: when using them in preload they are methods of the `p5` object, when using them inside your sketch they are methods of the `p` (in my case) object.\n\n### loadImage\n\n> `loadImage(filename: String[, callback: Function])`\n\nreturns: Promise\n\n### loadJSON\n\n> `loadJSON(filename: String[, callback: Function]);`\n\nreturns: Promise\n\n### loadStrings\n\n> `loadStrings(filename: String[, callback: Function]);`\n\nreturns: Promise\n\n\n\n## Built-in save functions\n\n### saveCanvas\n\n> `saveCanvas(canvas: Canvas, filename: String [, extension: String])`\n\nreturns: Promise\n\n### saveFrames\n\nSaves the frames as `png` or `jpg` in the output folder with names like `frame-001.png`, or as a gif with the name of the folder.\n\n> `saveFrames(canvas: Canvas, outFolder: String, extension: String, duration: Number, frameRate: Number)`\n\n- extension - `png` or `jpg`\n- duration - duration in seconds for how long to capture\n\n> `saveFrames(canvas: Canvas, outFolder: String, options: Object, duration: Number, frameRate: Number)`\n\nby replacing the extension with an object we are saving the animation as a gif\n\navailable options:\n\n- repeat (0 for repeat, -1 for no repeat)\n- quality (0 - 10) - the quality of the gif\n\nreturns: Promise\n\n### saveJSON\n\nSaves an Object as a JSON file\n\n> `saveJSON(object: Object, filename: String[, optimize: Boolean])`\n\n- object - the JavaScript object that you are saving\n- filename - the filename\n- optimize - If true, removes line breaks and spaces from the output file to optimize file size (but not readability). [default: false]\n\nreturns: Promise\n\n### saveStrings\n\nSaves an array of strings as a file\n\n> `saveStrings(list: Array, filename: String[, extension: String, separator: String])`\n\n- list - the JavaScript array that you are saving\n- filename - the filename\n- extension - the file extension [default: txt]\n- separator - what to separate the items of the array with [default: `\\n` (new line)]\n\nreturns: Promise\n\n## Registering your own methods\n\n`p5.registerMethod(name: String, method: Function)`\n\n```js\np5.registerMethod('addNumbers', (x, y) => {\n   return x + y; \n});\n...\nfunction sketch(p) {\n    p.setup = () => {\n        console.log(p.addNumbers(20, 5)); //25\n        p.noLoop();\n    }\n}\n```\n\nDon't use arrow notation if you want to use p5 features in your methods. If you use arrow notation the module cannot bind p5 to your method and thus you won't be able to use it.\n\n```js\np5.registerMethod('methodName', (arg1, arg2) => {\n    console.log(this.p5); //undefined\n});\n\np5.registerMethod('methodName', function(arg1, arg2) {\n    console.log(this.p5); //the p5 object (with all the methods)\n});\n```\n\nThe following strings can be passed to `registerMethod` instead of the method name to affect when that method is automatically called.\n\n- **pre** — Called at the beginning of `draw()`. It can affect drawing.\n- **post** — Called at the end of `draw()`.\n- **init** — Called when the sketch is first initialized, just before the sketch initialization function (the one that was passed into the `p5`constructor) is executed.\n\nExample:\n\n```js\np5.registerMethod('init', () => {\n    console.log('called when initialization is finished');\n});\n\np5.registerMethod('pre', () => {\n    console.log('every frame, at the start of draw');\n});\n\np5.registerMethod('post', () => {\n    console.log('every frame, at the end of draw');\n});\n```\n\n\n\n## Registering your own plugins\n\nWant to create your own plugins? I've got you covered fam.\n\n```js\n//myp5Plugin.js\nmodule.exports = {\n    mapNumbers: function(arg1, arg2, arg3, arg4, arg5) {\n        return this.p5.map(arg1, arg2, arg3, arg4, arg5);\n    }\n}\n```\n\n```js\nlet p5 = require('node-p5');\np5.registerPlugin(require('./myp5Plugin'));\n\nfunction sketch(p) {\n    p.setup = () => {\n        console.log(p.mapNumbers(5, 1, 10, 1, 100)); //45\n        p.noLoop();\n    }\n}\n\nlet p5Instance = p5.createSketch(sketch);\n```\n\n\n\n\n\n[p5js]: https://p5js.org\t\"p5 js\"","readmeFilename":"README.md"}