{"id":21915331,"url":"https://github.com/tim-harding/squircle","last_synced_at":"2025-04-18T12:28:03.060Z","repository":{"id":257502059,"uuid":"858434109","full_name":"tim-harding/squircle","owner":"tim-harding","description":"Smoothest CSS squircles south of Saskatchewan","archived":false,"fork":false,"pushed_at":"2024-10-23T23:22:15.000Z","size":217,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-12T12:06:48.224Z","etag":null,"topics":["css-houdini","squircle","superellipse"],"latest_commit_sha":null,"homepage":"https://tim-harding.github.io/squircle/","language":"JavaScript","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/tim-harding.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","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":"2024-09-16T22:15:11.000Z","updated_at":"2025-04-09T18:08:57.000Z","dependencies_parsed_at":"2024-10-04T20:16:37.038Z","dependency_job_id":"579e0a7e-eeb3-4e5c-ac3f-e3c9a2986d99","html_url":"https://github.com/tim-harding/squircle","commit_stats":null,"previous_names":["tim-harding/paint-squircle","tim-harding/superellipse-squircle","tim-harding/squircle"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tim-harding%2Fsquircle","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tim-harding%2Fsquircle/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tim-harding%2Fsquircle/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tim-harding%2Fsquircle/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tim-harding","download_url":"https://codeload.github.com/tim-harding/squircle/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248565058,"owners_count":21125417,"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":["css-houdini","squircle","superellipse"],"created_at":"2024-11-28T19:11:01.153Z","updated_at":"2025-04-18T12:28:02.989Z","avatar_url":"https://github.com/tim-harding.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Squircle [![Version](https://img.shields.io/npm/v/superellipse-squircle)](https://www.npmjs.com/package/superellipse-squircle)\n\nThe smoothest CSS squircles south of Saskatchewan. Powered by superellipses and\nCSS Houdini 🪄. Visit the project site and [experience the\nmagic](https://tim-harding.github.io/squircle/) or read about [how it\nworks](https://tim-harding.github.io/blog/squircles/).\n\n## Usage\n\n### CSS\n\nFirst, register the squircle web worker.\n\n```js\nimport { register } from \"superellipse-squircle\";\nregister();\n```\n\nNow you can use `paint(squircle)` as a image source in CSS. Usually that will be\n`background: paint(squircle);`, in which case you can use the provided\n`squircle` class. This includes a fallback to normal rounded rectangles when CSS\nHoudini isn't available.\n\n```html\n\u003cdiv\n  class=\"squircle\"\n  style=\"\n    --squircle-border-radius: 1rem;\n    --squircle-background-color: black;\"\n\u003e\u003c/div\u003e\n;\n```\n\nThese properties control the squircle drawing:\n\n| Property                      | Equivalent         |\n| ----------------------------- | ------------------ |\n| `--squircle-background-color` | `background-color` |\n| `--squircle-border-radius`    | `border-radius`    |\n| `--squircle-border-width`     | `border-width`     |\n| `--squircle-border-color`     | `border-color`     |\n\nTo reduce the verbosity, consider using aliases:\n\n```css\n.squircle {\n  --squircle-background-color: var(--fill);\n  --squircle-border-radius: var(--radius);\n  --squircle-border-width: var(--border-width);\n  --squircle-border-color: var(--border-color);\n}\n```\n\n### Web component\n\nThe `squircle` class falls back to normal rounded rectangles on browsers that\ndon't support the Paint API, which is [most of\nthem](https://caniuse.com/css-paint-api) at time of writing. To guarantee\nsquircles on all platforms, you can use the web component instead. It will add\nan HTML5 `\u003ccanvas\u003e` to draw with when the Paint API isn't available.\n\n```js\nimport { createCustomElement } from \"superellipse-squircle\";\ncreateCustomElement();\n```\n\n```html\n\u003cce-squircle\n  background-color=\"rgba(64, 128, 192, 0.5)\"\n  border-radius=\"16\"\n  border-width=\"4\"\n  border-color=\"black\"\n\u003e\n  Hello, world!\n\u003c/ce-squircle\u003e\n```\n\n### Canvas\n\nYou can also use the squircle drawing code directly in an HTML canvas. Import\nthe `paint` function to draw into a canvas context.\n\n```js\nimport { draw, paint } from \"superellipse-squircle\";\n\n// Just create a path\ndraw(canvasContext, posX, posY, width, height, borderRadius);\n\n// Draw the squircle with stroke and fill\npaint(\n  canvasContext,\n  posX,\n  posY,\n  width,\n  height,\n  borderRadius,\n  borderWidth,\n  fillColor,\n  borderColor,\n);\n```\n\n### SVG\n\nYou can create a string that is compatible with SVG `path` elements.\n\n```svg\n\u003csvg viewBox=\"0 0 512 512\"\u003e\n  \u003cpath id=\"my-path\" /\u003e\n\u003c/svg\u003e\n```\n\n```js\nimport { path } from \"superellipse-squircle\";\n\nconst d = path(0, 0, 512, 512, myRadius);\nconst path = document.getElementById(\"my-path\");\npath.d = d;\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftim-harding%2Fsquircle","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftim-harding%2Fsquircle","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftim-harding%2Fsquircle/lists"}