{"_id":"@brancisco/p5-bezier-builder","_rev":"4-1c292b92f4609bc544e08de554a9ee48","name":"@brancisco/p5-bezier-builder","dist-tags":{"latest":"1.0.2"},"versions":{"1.0.0":{"name":"@brancisco/p5-bezier-builder","version":"1.0.0","description":"A small library and tool to build complex bezier shapes for p5 sketches","main":"lib/index.js","types":"lib/index.d.ts","scripts":{"test":"jest","build":"tsc"},"repository":{"type":"git","url":"git+https://github.com/brancisco/p5-bezier-builder.git"},"keywords":["p5","p5js","processing","bezier"],"author":{"name":"Brandon Aguirre"},"license":"ISC","bugs":{"url":"https://github.com/brancisco/p5-bezier-builder/issues"},"homepage":"https://github.com/brancisco/p5-bezier-builder#readme","dependencies":{},"devDependencies":{"@babel/core":"^7.12.3","@babel/plugin-proposal-class-properties":"^7.12.1","@babel/plugin-proposal-private-methods":"^7.12.1","@babel/preset-env":"^7.12.1","@babel/preset-typescript":"^7.12.1","@fortawesome/fontawesome-svg-core":"^1.2.32","@fortawesome/free-solid-svg-icons":"^5.15.1","@fortawesome/vue-fontawesome":"^2.0.0","@types/jest":"^26.0.15","babel-jest":"^26.6.2","babel-loader":"^8.1.0","css-loader":"^5.0.1","jest":"^26.6.2","p5":"^1.1.9","style-loader":"^2.0.0","ts-jest":"^26.4.3","tslint":"^6.1.3","typescript":"^4.0.5","vue":"^2.6.12","vue-loader":"^15.9.5","vue-template-compiler":"^2.6.12","webpack":"^5.4.0","webpack-cli":"^4.2.0","webpack-dev-server":"^3.11.0"},"directories":{"lib":"lib"},"gitHead":"2940570ecc74fa9aa2320b23f873ffd6191588ce","_id":"@brancisco/p5-bezier-builder@1.0.0","_nodeVersion":"10.16.0","_npmVersion":"6.9.0","dist":{"integrity":"sha512-niUIemZNRiTx5hGFSmUIRjwtM21N3pcCIDojHihyUSzlI7ZK0fZ4kInvocixC0ZioSU8T/4ALkV47LRb7WSNlw==","shasum":"cc060b107add739ed24b0ec5ffdb70adb85bf092","tarball":"https://registry.npmjs.org/@brancisco/p5-bezier-builder/-/p5-bezier-builder-1.0.0.tgz","fileCount":11,"unpackedSize":37048,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfrCFVCRA9TVsSAnZWagAAyncP/17tp5digwbqJ3vKX+G6\nCRDqqU4f5knuFDA3wpuIFv3YuM26Mdn9krHvx4xBpDux5on5DDFhRShEfucs\n5MNSG1wQruZQc2xkqev+IaOUiJUH3lITo5FUxwvE2SRDTUFPoteLR+fvngmG\njEPqAaGkmPja2l+8AVks2XyY5AtOF3/dVqiW1SbJcgVnv8EP9rPkpPzngodY\nRC1udBfCI5+vPmiUtNmTUmVhXdviSnMRyqh88duRzvKH/iohbasshwB+j5/x\nkge0HIP8a7c52A/k+03D9YGkEBi3+9df+vpYCN7+/CtG8dbyqwtuYPeIl0vE\nKAp7+r7XtnvDP4myjv9eeVJagqUnf76+MLhs6oqTy1Kgcr9oTQYTq+S/fBS8\n/oX6M3qPa32ejW2VPZ8Ib4WA2FMpr+ihm6gaiHobMKN7g5uqZ7+4K6Pl51fU\n0CAGj8vIOSh3The9skD31KCGSzD3fZGq/V6Q5cyv+micB3tCyPInL2KJM0we\nI3Et+YVg6X/uYvfzVTij81B0w7HssO8sOtVn5oLpKvLeJ2xhZMNbRZ+tqBKx\nZh5x3IuGIYwCtocwOLGfF/uj9vTzpY8lvYXvVaxX8x61zj2zpxHSPDcHGeM/\nt+89uEipTJaGkEiJ1BEvXVBW92cSgHdsNXv7CGLPpm2xkqnOzYjBxMsUk3a7\nLoOD\r\n=3iHT\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIDqqBge7V7lgc1VBY8xwB56aLrt+gMZaYD4U568gag4vAiA+0A19cJ+VX7secixDbpHIJbW653SbhZLbld8ZbiVi6Q=="}]},"_npmUser":{"name":"brancisco","email":"baguirre1249@gmail.com"},"maintainers":[{"name":"brancisco","email":"baguirre1249@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/p5-bezier-builder_1.0.0_1605116245275_0.10618355901062126"},"_hasShrinkwrap":false},"1.0.1":{"name":"@brancisco/p5-bezier-builder","version":"1.0.1","description":"A small library and tool to build complex bezier shapes for p5 sketches","main":"lib/index.js","types":"lib/index.d.ts","scripts":{"test":"jest","build":"tsc"},"repository":{"type":"git","url":"git+https://github.com/brancisco/p5-bezier-builder.git"},"keywords":["p5","p5js","processing","bezier"],"author":{"name":"Brandon Aguirre"},"license":"ISC","bugs":{"url":"https://github.com/brancisco/p5-bezier-builder/issues"},"homepage":"https://brancisco.github.io/p5-bezier-builder/","dependencies":{},"devDependencies":{"@babel/core":"^7.12.3","@babel/plugin-proposal-class-properties":"^7.12.1","@babel/plugin-proposal-private-methods":"^7.12.1","@babel/preset-env":"^7.12.1","@babel/preset-typescript":"^7.12.1","@fortawesome/fontawesome-svg-core":"^1.2.32","@fortawesome/free-solid-svg-icons":"^5.15.1","@fortawesome/vue-fontawesome":"^2.0.0","@types/jest":"^26.0.15","babel-jest":"^26.6.2","babel-loader":"^8.1.0","css-loader":"^5.0.1","jest":"^26.6.2","p5":"^1.1.9","style-loader":"^2.0.0","ts-jest":"^26.4.3","tslint":"^6.1.3","typescript":"^4.0.5","vue":"^2.6.12","vue-loader":"^15.9.5","vue-template-compiler":"^2.6.12","webpack":"^5.4.0","webpack-cli":"^4.2.0","webpack-dev-server":"^3.11.0"},"directories":{"lib":"lib"},"gitHead":"616c75c2950b30e1d2acebb3a0bc83669c6b03ca","_id":"@brancisco/p5-bezier-builder@1.0.1","_nodeVersion":"10.16.0","_npmVersion":"6.9.0","dist":{"integrity":"sha512-HZMcoEdjuMUjs8vtsA0VSMWKyf8LliD1HYVJ04OH+Jj9SistXZaMN9cV+GoNtrx3te9Tm39uSJ2y6SDb9fgpGA==","shasum":"748d78a77b8fae45a9aafb7f5ccc3a59335d8804","tarball":"https://registry.npmjs.org/@brancisco/p5-bezier-builder/-/p5-bezier-builder-1.0.1.tgz","fileCount":11,"unpackedSize":43585,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfrbH3CRA9TVsSAnZWagAAHuYQAILPnTVzjl4jukywig58\nBCrp64rDKY4fvuZD0x/uTNT38Jq01UZLMmZG0a7bh/5JFSmnpnYBv+v/itGl\nRdU2VX0XKUh1U2fGioaqC3TykUvigzDFKGDPcMUdq4CpZ+B5A/zieQGmJELq\nkxB+kT4Xzj3ZKPrRzeN/twOvaxzwEnnEB0g8DvgLa/1Z4bufBl4DE4l9hPgt\nYVFJTW3xw619tUUdSncy959NKc5iW/JJERNdkwh/IBpoyWLMFzdRv5hW9V6a\nUgBp49eBBDCgVpx/ykWSl5c722mnt3YS4pC4rHdNcNfnHV6RWY1qlhkQgaiQ\nLXkf10VNW5NXuJEKq2tHS2xPAK50z6KSFDnixc6IsB7tLbrwxvQpe//xkqAj\ncBW8kVikW70eXWGBxq8dS2oRch2v2o6vjAgb3vJmS+reUBtyN1pWo3ha7ndK\nsb1tZfxhbC4CqSM1MrXLMztH/qJu4IBCyhUsCSaHbdR5BNx3dBjUahZCs/w9\nyak3jaB1NGZqjZp7UZPsEHRd0HYVw5Ji77O1izwSOAdbgdu4/z2T5/PN/r7T\nDRqh/XPqnl/vKzyEAkvQJIz3kIWgxyFqMFHng+hZSIy0VUCuQfjXWWjNdJpZ\nQqG3GH1KkH2lZ2zW1JwrWwNwiRERVO3ynJ+FXqwGD2HF6OulpTKtXcr5/+ds\nSKZ4\r\n=GVd2\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCUbxyAI6lqapr2mzeN+5yKHID7EI9b+8tvEVg6EkYspgIhAI7BPIqHkGAw8JSvjQEU5x0USVpgUl9eyDAk0KOaVc4T"}]},"_npmUser":{"name":"brancisco","email":"baguirre1249@gmail.com"},"maintainers":[{"name":"brancisco","email":"baguirre1249@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/p5-bezier-builder_1.0.1_1605218806540_0.9842550181240428"},"_hasShrinkwrap":false},"1.0.2":{"name":"@brancisco/p5-bezier-builder","version":"1.0.2","description":"A small library and tool to build complex bezier shapes for p5 sketches","main":"lib/index.js","types":"lib/index.d.ts","scripts":{"test":"jest","build":"tsc"},"repository":{"type":"git","url":"git+https://github.com/brancisco/p5-bezier-builder.git"},"keywords":["p5","p5js","processing","bezier"],"author":{"name":"Brandon Aguirre"},"license":"ISC","bugs":{"url":"https://github.com/brancisco/p5-bezier-builder/issues"},"homepage":"https://brancisco.github.io/p5-bezier-builder/","dependencies":{},"devDependencies":{"@babel/core":"^7.12.3","@babel/plugin-proposal-class-properties":"^7.12.1","@babel/plugin-proposal-private-methods":"^7.12.1","@babel/preset-env":"^7.12.1","@babel/preset-typescript":"^7.12.1","@fortawesome/fontawesome-svg-core":"^1.2.32","@fortawesome/free-solid-svg-icons":"^5.15.1","@fortawesome/vue-fontawesome":"^2.0.0","@types/jest":"^26.0.15","babel-jest":"^26.6.2","babel-loader":"^8.1.0","css-loader":"^5.0.1","jest":"^26.6.2","p5":"^1.1.9","style-loader":"^2.0.0","ts-jest":"^26.4.3","tslint":"^6.1.3","typescript":"^4.0.5","vue":"^2.6.12","vue-loader":"^15.9.5","vue-template-compiler":"^2.6.12","webpack":"^5.4.0","webpack-cli":"^4.2.0","webpack-dev-server":"^3.11.0"},"directories":{"lib":"lib"},"gitHead":"1867d0bb729227354c3cf818b8d5271b0bdaeaa0","_id":"@brancisco/p5-bezier-builder@1.0.2","_nodeVersion":"16.0.0","_npmVersion":"6.14.15","dist":{"integrity":"sha512-WyL+X5Ew3OWewNzYBvDwgFnYUdlwlWuj1+0wQXXQBNzFzWSEmSdvpYKkRw9MmetzSV6WuPl3UdocTiNgxhe/Xg==","shasum":"64873cbce2573d9feb61157f63938c1322f8eb5d","tarball":"https://registry.npmjs.org/@brancisco/p5-bezier-builder/-/p5-bezier-builder-1.0.2.tgz","fileCount":11,"unpackedSize":43706,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJhzZucCRA9TVsSAnZWagAAoToP/R1kpBFV8AemG3pXHo/8\nHBhuMoRs+nuT+UZvEz187YoZPMr3MKcldIuwVnLJHyphEturY46DziUIyDFC\nO+ssut+6trL+0bPJDYkqH/yuJdU9WV8xFNtXn+z8OiY1Q3VUtXaA32y/5AqS\nvVyYu/gKC9qWSPcFthJ9CJxSQKb+AodmytvnHHfJTxu6xtP5lbbQg7fZl6v5\nTWjnatYyFTkoG8IoFMA4j+4KHQ2WIsutElhWDnjqyoqjh/Sw+x085YIGfeaW\nPsIdnxW/09A7Nx8vRhxVCeJ3GjLKC8SuD7dWX520ONE3As3L51Wzbbx9jmXR\nM1STe1Ay0/OcGRzcsEBn8orlRRbR5VaP01iSrJ4HEf+0m+fwKj0lp/oGuou2\nY2jJBi11RhXxTCvodvtOtQGrHswHTnojXXrAoI8/iv03ih2SGb6U+ao7mIna\nNXqlb0XdyHykEyHw4dyDo66SeAaGIqDwuq0RTukqea0ddJjtQifM7Ev6oJWT\neDJoRkM6ClPoURrATFF0EruhgZk+YCPTL2vxN1OOjZDnX9uQpt1FearrxDej\npFZ15Fa/dCPojpgUPlwa1B5BZPKrhoO87ouISom+aGIWCoV4GCnJRFizZnWb\n1rlboTrC+8L4yEX/k4/rG467M3sO+JcUbJKK7DtfMtnQ2tBBsxt/PdVDGr6a\nkRMx\r\n=tzlD\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIAcTPCKH2dKe9A1JK1cBB3/WFwMbgU+C4phGJuI7V6o6AiBxcA6a4vTks/JVSnrduzfx14xWtm0qU4IugiA2gGkQ9Q=="}]},"_npmUser":{"name":"brancisco","email":"baguirre1249@gmail.com"},"maintainers":[{"name":"brancisco","email":"baguirre1249@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/p5-bezier-builder_1.0.2_1634840455076_0.7475138417593679"},"_hasShrinkwrap":false}},"time":{"created":"2020-11-11T17:37:25.225Z","1.0.0":"2020-11-11T17:37:25.403Z","modified":"2022-04-04T20:21:59.016Z","1.0.1":"2020-11-12T22:06:46.695Z","1.0.2":"2021-10-21T18:20:55.253Z"},"maintainers":[{"name":"brancisco","email":"baguirre1249@gmail.com"}],"description":"A small library and tool to build complex bezier shapes for p5 sketches","homepage":"https://brancisco.github.io/p5-bezier-builder/","keywords":["p5","p5js","processing","bezier"],"repository":{"type":"git","url":"git+https://github.com/brancisco/p5-bezier-builder.git"},"author":{"name":"Brandon Aguirre"},"bugs":{"url":"https://github.com/brancisco/p5-bezier-builder/issues"},"license":"ISC","readme":"# p5-bezier-builder\nA small library and tool to build complex bezier shapes for p5 sketches\n\n## Check out the demo webpage\n\nhttps://brancisco.github.io/p5-bezier-builder/\n\n![Example Image](./meta/img/example.png)\n\n## Getting Started\n\n### Installing\n\n```\nnpm i @brancisco/p5-bezier-builder\n```\n\n### Drawing a bezier shape\n\nIn your p5 sketch to draw beziers use the `BezierShape` class\n\n```js\nimport { BezierShape } from '@brancisco/p5-bezier-builder'\n\nconst sketch = function (p) {\n    let myshape;\n    p.setup = function setup (p5) {\n        const myshape = new BezierShape([\n            [0, 0], [10, 10], [20, 20], [30, 30] // [, nth vertex]\n        ]);\n    };\n\n    p.draw = function draw (p5) {\n        p5.background(255)\n        p5.fill(0)\n        myshape.draw(p5)\n    };\n};\n```\n\n### Helper to create bezier shapes\n\n- Use the demo\n\n1. Visit: https://brancisco.github.io/p5-bezier-builder/\n2. Draw your shape (or shapes)\n3. Click the export button in the demo\n4. Move the file into your project\n5. (Optional for ease): make the file a .js file and write `export default () => [/* ... exported beziers here */]`\n6. Import the file into your sketch. e.g.,  `import mybezierdata from \"./path/to/my/BezierSketch.js\"`\n7. Use the BezierShape class to draw your bezier in your sketch\n\n\n```js\nimport { BezierShape } from '@brancisco/p5-bezier-builder'\nimport mybezierdata from './path/to/my/BezierSketch.js'\n\nconst sketch = function (p) {\n    let myshape;\n    p.setup = function setup (p5) {\n        const myshape = new BezierShape(mybezierdata());\n        myshape.setPosition(100, 100) // sets the position at x: 100, y: 100\n        myshape.setDim(50, 50) // changes the dimensions of your shape to w: 50, h: 50\n    };\n\n    p.draw = function draw (p5) {\n        p5.background(255)\n        p5.fill(0)\n        myshape.draw(p5)\n    };\n};\n```\n\nOR create your own tool:\n\n- To create a bezier shape use the `BezierShapeBuilder` helper class.\n\n```js\nimport { BezierShapeBuilder } from '@brancisco/p5-bezier-builder'\n\nconst sketch = function (p) {\n    let builder;\n    p.setup = function setup (p5) {\n        const builder = new BezierShape();\n    };\n\n    p.draw = function draw (p5) {\n        p5.background(255);\n        p5.fill(0);\n        builder.update(p5);\n        builder.draw(p5);\n    };\n\n    p5.mousePressed = (event) => {\n        builder.handleEvent('mousePressed', event);\n    };\n\n    p5.mouseClicked = (event) => {\n        builder.handleEvent('mouseClicked', event);\n    };\n\n    p5.mouseReleased = (event) => {\n        builder.handleEvent('mouseReleased', event);\n    };\n\n    p5.keyPressed = (event) => {\n        builder.handleEvent('keyPressed', event);\n    };\n};\n```\n\n## BezierShape Methods\n\n### Transformations\n\n#### shift()\n\n```ts\n/**\n * Shifts all vertices by the amount provided in x, and y direction\n *\n * @param {number} x - The number to shift in x direction\n * @param {number} [y=0] - The number to shift in the y direction\n */\nshift (x: number, y: number = 0): void;\n```\n\n#### setPosition()\n\n```ts\n/**\n * Set the position of the bezier shape (BOTTOM, LEFT CORNER is the origin)\n *\n * @param {number} x - The x position of the bezier\n * @param {number} y - The y position of the bezier\n */\nsetPosition (x: number, y: number): void;\n```\n\n#### setDim()\n\n```ts\n/**\n * Set the dimensions of the bezier\n * \n * @param {number} w - The width of the bezier\n * @param {number|null} [h=null] - The height of the bezier\n */\nsetDim (w: number, h: number | null = null): void;\n```\n\n#### scale()\n\n```ts\n/**\n * Scales the bezier shape by a factor of the number provied\n *\n * @param {number} scale - The number to scale the bezier shape by\n */\nscale (scale: number): void;\n```\n\n#### applyToVertices()\n\nNote: Currently if you use this function, the rectangular boundary is not recomputed. You must manually\nassign the `rect` property to the return value of `computeRectangle()`. For Example:\n\n```js\n// square the verts\nmyshape.applyToVertices(v => [v[0]**v[0], v[1]**v[1]])\nmyshape.rect = myshape.computeRectangle()\n```\n\n```ts\n/**\n * Applies a function f to all vertices v\n *\n * @param {(v: Vertex) => Vertex} f - The function to apply to the vertices\n */\napplyToVertices (f: (v: Vertex) => Vertex): void\n```\n\n### Getters\n\n#### getDim()\n\n```ts\n/**\n * Get the dimensions of the bezier\n *\n * @returns {[NumUnk, NumUnk]} - The dimension of the bezier\n */\ngetDim (): [NumUnk, NumUnk];\n```\n\n#### getRectangularBoundary()\n\n```ts\n/**\n * Get the rectangular boundary of the bezier\n *\n * @returns {Boundary} - In the form of [top, right, bottom, left]\n */\ngetRectangularBoundary (): Boundary;\n```\n\n#### getBezier()\n\n```ts\n/**\n * Returns the ith bezier curve\n *\n * @param {number} i - The index of the bezier curve to get\n * @returns {[Vertex, Vertex, Vertex, Vertex]}\n */\ngetBezier (i: number): [Vertex, Vertex, Vertex, Vertex];\n```\n\n### Vertex / Shape Manipulation\n\n#### push()\n\n```ts\n/**\n * Add a vertex to the vertices\n *\n * @param {number} x - The x position of new vertex\n * @param {number} y - The y position of new vertex\n */\npush (x: number, y: number): void;\n```\n\n#### pop()\n\n```ts\n/**\n * Remove (and get) a vertex from vertices\n *\n * @returns {Vertex|undefined}\n */\npop (): Vertex | undefined;\n```\n\n#### concat()\n\n```ts\n/**\n * Add multiple vertices to the bezier vertices\n *\n * @param {Vertices} vertices - The vertices to add to the shape\n */\nconcat (vertices: Vertices): void;\n```\n\n#### splice()\n\n```ts\n/**\n * Removes vertices from the bezier vertices, and if necessary replaces vertices with new ones,\n * returning the removed elements\n *\n * @param {number} start - The zero-based index to start removing vertices from\n * @param {number|undefined} deleteCount - The number of vertices to remove\n * @param {Vertices|undefined} replace - The vertices to replace the removed\n *\n * @returns {Vertices}\n */\nsplice (start: number, deleteCount?: number, replace?: Vertices): Vertices;\n```\n\n#### insert()\n\n```ts\n/**\n * Insert vertices into the bezier vertices.\n * Same as splice(start, 0, vertices)\n *\n * @param {number} start - The zero-based index to insert at\n * @param {Vertices} vertices - The vertices to insert\n */\ninsert (start: number, vertices: Vertices): void\n```\n\n\n## Todo\n\n- Add Feat: auto-close shape\n- Write tests\n- Make demo mobile friendly\n- Add demo functionality to save shapes to local storage\n- Add demo functionality to remove curves from any index withing bezier shape\n- Add demo functionality to insert points into a bezer shape","readmeFilename":"README.md"}