{"id":22356844,"url":"https://github.com/ayamflow/glsl-2d-primitives","last_synced_at":"2026-02-13T01:05:58.564Z","repository":{"id":143880339,"uuid":"126882572","full_name":"ayamflow/glsl-2d-primitives","owner":"ayamflow","description":"SDF functions to draw 2d shapes in glsl.","archived":false,"fork":false,"pushed_at":"2018-03-27T17:01:58.000Z","size":9,"stargazers_count":39,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-16T09:41:27.507Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"GLSL","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/ayamflow.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-03-26T19:55:37.000Z","updated_at":"2024-10-08T17:18:47.000Z","dependencies_parsed_at":null,"dependency_job_id":"e7258e2f-6ede-4665-b5f2-16e4f7f74d70","html_url":"https://github.com/ayamflow/glsl-2d-primitives","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ayamflow%2Fglsl-2d-primitives","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ayamflow%2Fglsl-2d-primitives/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ayamflow%2Fglsl-2d-primitives/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ayamflow%2Fglsl-2d-primitives/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ayamflow","download_url":"https://codeload.github.com/ayamflow/glsl-2d-primitives/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245659026,"owners_count":20651526,"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":[],"created_at":"2024-12-04T14:12:11.485Z","updated_at":"2026-02-13T01:05:53.529Z","avatar_url":"https://github.com/ayamflow.png","language":"GLSL","funding_links":[],"categories":[],"sub_categories":[],"readme":"# glsl-2d-primitives\n\n[![stable](http://badges.github.io/stability-badges/dist/stable.svg)](http://github.com/badges/stability-badges)\n\nSDF functions to draw 2d shapes in glsl.\nAntialiased using [glsl-aastep](https://github.com/glslify/glsl-aastep).\n\n![glsl-2d-primitives](https://i.imgur.com/qJmmSxA.jpg)\n\n### Installation :package:\n\n```bash\nnpm i glsl-2d-primitives -S\n```\n\n### Usagez :book:\n\n#### circle(vec2 st, float radius)\n#### rectangle(vec2 st, vec2 size)\n#### polygon(vec2 st, float radius, float sides)\n\n### Example :floppy_disk:\n\n```glsl\n#pragma glslify: circle = require(glsl-2d-primitives/circle)\n#pragma glslify: rectangle = require(glsl-2d-primitives/rectangle)\n#pragma glslify: polygon = require(glsl-2d-primitives/polygon)\n\nattribute vec2 vUv;\nuniform sampler2D map;\n\nvoid main() {\n    gl_FragColor = texture2D(map, vUv);\n    // Mask the image with a centered rectangle\n    gl_FragColor.a = rectangle(vUv, vec2(0.4, 0.6));\n\n    // Draw a pentagon, without alpha masking\n    gl.FragColor = vec4(vec3(polygon(vUv, 0.4, 5.0)), 1.0);\n\n    // Mask the image with a ring, combining 2 circles\n    float ring = circle(vUv, 0.5) * (1.0 - circle(vUv, 0.52));\n    gl_FragColor.a = ring;\n}\n```\n\n[Demo](http://thebookofshaders.com/edit.php?log=180326195904)\n\n### See also\n- https://thebookofshaders.com/07/\n- https://github.com/glslify/glsl-aastep\n- https://github.com/marklundin/glsl-sdf-primitives\n\n### License :pencil:\n\nMIT. See [LICENSE](http://github.com/ayamflow/glsl-layer/blob/master/LICENSE) for details.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fayamflow%2Fglsl-2d-primitives","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fayamflow%2Fglsl-2d-primitives","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fayamflow%2Fglsl-2d-primitives/lists"}