{"id":16225748,"url":"https://github.com/macfja/svelte-p5","last_synced_at":"2025-03-19T12:31:06.932Z","repository":{"id":57127264,"uuid":"306931884","full_name":"MacFJA/svelte-p5","owner":"MacFJA","description":"Small wrapper around P5 for Svelte","archived":false,"fork":false,"pushed_at":"2022-08-05T20:21:35.000Z","size":17,"stargazers_count":10,"open_issues_count":1,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-17T07:11:19.893Z","etag":null,"topics":["p5js","svelte","svelte-component","sveltejs"],"latest_commit_sha":null,"homepage":"","language":"Svelte","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/MacFJA.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-10-24T17:06:30.000Z","updated_at":"2023-04-26T09:36:12.000Z","dependencies_parsed_at":"2022-08-31T17:20:28.793Z","dependency_job_id":null,"html_url":"https://github.com/MacFJA/svelte-p5","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MacFJA%2Fsvelte-p5","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MacFJA%2Fsvelte-p5/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MacFJA%2Fsvelte-p5/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MacFJA%2Fsvelte-p5/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/MacFJA","download_url":"https://codeload.github.com/MacFJA/svelte-p5/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244426598,"owners_count":20450994,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["p5js","svelte","svelte-component","sveltejs"],"created_at":"2024-10-10T12:46:09.330Z","updated_at":"2025-03-19T12:31:06.686Z","avatar_url":"https://github.com/MacFJA.png","language":"Svelte","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Svelte P5 wrapper\n\nThe small wrapper allow the usage of p5*js in Svelte\n\n## Installation\n\n```\nnpm install @macfja/svelte-p5\n```\n\n## Usage \u0026 Examples\n\nThe component (`\u003cP5 /\u003e`) execute every functions that are pass as a p5*js function.\nEvery function have access to 3 parameters:\n- 1st parameter: The current sketch context (`createVector`, `circle`, `fill`, etc.)\n- 2nd parameter: The map of p5*js classes (`Color`, `Geometry`, `Shader`, etc.)\n- 3rd parameter: The map of p5*js constants (`BURN`, `DEG_TO_RAD`, `PI`, `RIGHT_ARROW`, etc.)\n\n```html\n\u003cscript\u003e\nimport P5 from \"@macfja/svelte-p5\"\n\nfunction setup(p5, classes, constants) {\n  p5.createCanvas(400, 400);\n}\n\nfunction draw(p5, classes, constants) {\n  p5.background(220);\n  p5.ellipse(50,50,80,80);\n}\n\u003c/script\u003e\n\n\u003cP5 {setup} {draw} /\u003e\n```\n\n```html\n\u003cscript\u003e\nimport P5 from \"@macfja/svelte-p5\"\n\nlet y = 0;\nlet sketch = {\n  setup: p5 =\u003e {\n    p5.createCanvas(720, 400);\n    p5.stroke(255); // Set line drawing color to white\n    p5.frameRate(30);\n  },\n  draw: p5 =\u003e {\n    p5.background(0); // Set the background to black\n    y = y - 1;\n    if (y \u003c 0) {\n      y = p5.height;\n    }\n    p5.line(0, y, p5.width, y);\n  }\n}\n\u003c/script\u003e\n\n\u003cP5 {...sketch} /\u003e\n```\n\n```html\n\u003cscript\u003e\nimport P5 from \"@macfja/svelte-p5\"\n\nlet y = 0;\nlet speed = 30;\nlet current;\nlet sketch = {\n  setup: p5 =\u003e {\n    p5.createCanvas(720, 400);\n    p5.stroke(255); // Set line drawing color to white\n  },\n  draw: (p5) =\u003e {\n    p5.frameRate(speed);\n    p5.background(0); // Set the background to black\n    y = y - 1;\n    if (y \u003c 0) {\n      y = p5.height;\n    }\n    p5.line(0, y, p5.width, y);\n    current = p5.frameRate()\n  }\n}\n\u003c/script\u003e\n\n\u003cstyle\u003e\n\tlabel * {\n\t\tvertical-align: middle;\n\t}\n\u003c/style\u003e\n\n\u003clabel\u003eSpeed (frame rate): \u003cinput type=\"range\" min=\"1\" max=\"100\" bind:value=\"{speed}\" /\u003e {speed} (Current framerate: {Math.round((current + Number.EPSILON) * 100) / 100})\u003c/label\u003e\n\u003cP5 {...sketch} /\u003e\n```\n([REPL for the 3 example above](https://svelte.dev/repl/5501d3af4d8e4c2caa17324c9724a8f8?version=3.29.4))\n\n## Contributing\n\nContributions are welcome. Please open up an issue or create PR if you would like to help out.\n\nRead more in the [Contributing file](CONTRIBUTING.md)\n\n## License\n\nThe MIT License (MIT). Please see [License File](LICENSE.md) for more information.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmacfja%2Fsvelte-p5","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmacfja%2Fsvelte-p5","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmacfja%2Fsvelte-p5/lists"}