{"id":13580231,"url":"https://github.com/daybrush/overlap-area","last_synced_at":"2025-04-06T11:07:37.671Z","repository":{"id":37337788,"uuid":"309472565","full_name":"daybrush/overlap-area","owner":"daybrush","description":"Find the Overlap Area.","archived":false,"fork":false,"pushed_at":"2023-03-14T13:55:39.000Z","size":809,"stargazers_count":67,"open_issues_count":1,"forks_count":3,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-30T10:06:37.119Z","etag":null,"topics":["area","collision","javascript","overlap","overlapping","points","typescript"],"latest_commit_sha":null,"homepage":"https://daybrush.com/overlap-area","language":"TypeScript","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/daybrush.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}},"created_at":"2020-11-02T19:21:53.000Z","updated_at":"2025-03-08T11:45:26.000Z","dependencies_parsed_at":"2024-04-08T18:06:45.002Z","dependency_job_id":null,"html_url":"https://github.com/daybrush/overlap-area","commit_stats":{"total_commits":36,"total_committers":2,"mean_commits":18.0,"dds":0.02777777777777779,"last_synced_commit":"313f1b901d8cf4b5084846d66420b7c0527caefc"},"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/daybrush%2Foverlap-area","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/daybrush%2Foverlap-area/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/daybrush%2Foverlap-area/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/daybrush%2Foverlap-area/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/daybrush","download_url":"https://codeload.github.com/daybrush/overlap-area/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247471517,"owners_count":20944158,"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":["area","collision","javascript","overlap","overlapping","points","typescript"],"created_at":"2024-08-01T15:01:48.987Z","updated_at":"2025-04-06T11:07:37.652Z","avatar_url":"https://github.com/daybrush.png","language":"TypeScript","funding_links":[],"categories":["TypeScript"],"sub_categories":[],"readme":"\n\u003cp align=\"middle\" \u003e\u003cimg src=\"https://raw.githubusercontent.com/daybrush/overlap-area/master/demo/images/logo.png\" /\u003e\u003c/p\u003e\n\u003ch2 align=\"middle\"\u003eOverlap Area\u003c/h2\u003e\n\u003cp align=\"middle\"\u003e\n\u003ca href=\"https://www.npmjs.com/package/overlap-area\" target=\"_blank\"\u003e\u003cimg src=\"https://img.shields.io/npm/v/overlap-area.svg?style=flat-square\u0026color=007acc\u0026label=version\" alt=\"npm version\" /\u003e\u003c/a\u003e\n\u003cimg src=\"https://img.shields.io/badge/language-typescript-blue.svg?style=flat-square\"/\u003e\n\u003ca href=\"https://github.com/daybrush/overlap-area/blob/master/LICENSE\" target=\"_blank\"\u003e\u003cimg src=\"https://img.shields.io/github/license/daybrush/overlap-area.svg?style=flat-square\u0026label=license\u0026color=08CE5D\"/\u003e\u003c/a\u003e\n\u003c/p\u003e\n\u003cp align=\"middle\"\u003eFind the Overlap Area.\u003c/p\u003e\n\n\u003cp align=\"middle\"\u003e\n    \u003ca href=\"https://daybrush.com/overlap-area\" target=\"_blank\"\u003e\u003cstrong\u003eDemo\u003c/strong\u003e\u003c/a\u003e /\n    \u003ca href=\"https://daybrush.com/overlap-area/release/latest/doc/\" target=\"_blank\"\u003e\u003cstrong\u003eAPI\u003c/strong\u003e\u003c/a\u003e /\n    \u003ca href=\"https://github.com/daybrush/scena\" target=\"_blank\"\u003e\u003cstrong\u003eMain Project\u003c/strong\u003e\u003c/a\u003e\n\u003c/p\u003e\n\n## 📄 API Documents\n* [API documentation](https://daybrush.com/overlap-area/release/latest/doc/)\n\n## ⚙️ Installation\n```bash\n$ npm install overlap-area\n```\n\n```html\n\u003cscript src=\"//daybrush.com/overlap-area/release/latest/dist/overlap-area.min.js\"\u003e\u003c/script\u003e\n```\n\n## 🚀 How to use\n```ts\nimport { isInside, getOverlapPoints, getOverlapSize } from \"overlap-area\";\n\nconst points1 = [\n    [0, 0],\n    [100, 0],\n    [120, 100],\n    [0, 100],\n];\nconst points2 = [\n    [100, 0],\n    [150, 0],\n    [150, 100],\n    [100, 100],\n];\n\n// true\nconsole.log(isInside([50, 50], points1));\n// false\nconsole.log(isInside([50, 50], points2));\n\n// [100, 0], [120, 100], [100, 100]\nconsole.log(getOverlapPoints(points1, points2));\n\n// 1000\nconsole.log(getOverlapSize(points1, points2));\n```\n### User Overlap Areas\nGet the areas of the overlapped part of two shapes.\n\n![Overlap Areas](https://daybrush.com/overlap-area/images/overlap.png)\n\n```js\nimport { getOverlapAreas } from \"overlap-area\";\n\nconst points1 = [\n    [150, 100],\n    [200, 50],\n    [250, 60],\n    [300, 100],\n    [250, 160],\n    [150, 150],\n    [200, 120],\n];\nconst points2 = [\n    [250, 100],\n    [300, 50],\n    [350, 60],\n    [400, 100],\n    [350, 160],\n    [220, 150],\n    [300, 120],\n];\n\n/*\n[\n    [\n        [272.2222222, 77.7777778],\n        [300, 100],\n        [287.5, 115],\n        [250, 100],\n    ],\n    [\n        [275.7575758, 129.0909091],\n        [256.0240964, 152.7710843],\n        [220, 150],\n    ],\n]\n*/\nconsole.log(getOverlapAreas(points1, points2));\n```\n### User Unoverlap Areas\nGet non-overlapping areas of two shapes based on points1.\n\n\n![Unoverlap Areas](https://daybrush.com/overlap-area/images/unoverlap.png)\n\n```js\nimport { getUnoverlapAreas } from \"overlap-area\";\n\nconst points1 = [\n    [150, 100],\n    [200, 50],\n    [250, 60],\n    [300, 100],\n    [250, 160],\n    [150, 150],\n    [200, 120],\n];\nconst points2 = [\n    [250, 100],\n    [300, 50],\n    [350, 60],\n    [400, 100],\n    [350, 160],\n    [220, 150],\n    [300, 120],\n];\n\n/*\n[\n    [\n        [150, 100],\n        [200, 50],\n        [250, 60],\n        [272.2222222, 77.7777778],\n        [250, 100],\n        [287.5, 115],\n        [275.7575758, 129.0909091],\n        [220, 150],\n        [256.0240964, 152.7710843],\n        [250, 160],\n        [150, 150],\n        [200, 120],\n    ],\n]\n*/\nconsole.log(getUnoverlapAreas(points1, points2));\n```\n### Calculate the overlap of elements\n```js\nimport { getElementInfo } from \"moveable\";\nimport { getOverlapPoints, getOverlapSize } from \"overlap-area\";\n\nfunction getPoints(info) {\n    const { left, top, pos1, pos2, pos3, pos4 } = info;\n\n    return [pos1, pos2, pos4, pos3].map(pos =\u003e [left + pos[0], top + pos[1]]);\n}\n\nconst points1 = getPoints(getElementInfo(element1));\nconst points2 = getPoints(getElementInfo(element2));\n\n// Points of the overlapped area\ngetOverlapPoints(points1, points2);\n\n// Size of the overlapped area\ngetOverlapSize(points1, points2);\n```\n\n## ⭐️ Show Your Support\nPlease give a ⭐️ if this project helped you!\n\n## 👏 Contributing\n\nIf you have any questions or requests or want to contribute to `overlap-area` or other packages, please write the [issue](https://github.com/daybrush/overlap-area/issues) or give me a Pull Request freely.\n\n## 🐞 Bug Report\n\nIf you find a bug, please report to us opening a new [Issue](https://github.com/daybrush/overlap-area/issues) on GitHub.\n\n\n## 📝 License\n\nThis project is [MIT](https://github.com/daybrush/overlap-area/blob/master/LICENSE) licensed.\n\n```\nMIT License\n\nCopyright (c) 2020 Daybrush\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdaybrush%2Foverlap-area","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdaybrush%2Foverlap-area","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdaybrush%2Foverlap-area/lists"}