{"id":17036720,"url":"https://github.com/bast/polygenerator","last_synced_at":"2025-07-09T08:04:24.671Z","repository":{"id":57454052,"uuid":"409943971","full_name":"bast/polygenerator","owner":"bast","description":"Generates random simple polygons.","archived":false,"fork":false,"pushed_at":"2021-09-26T12:41:06.000Z","size":611,"stargazers_count":12,"open_issues_count":0,"forks_count":2,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-07-09T08:02:20.206Z","etag":null,"topics":["polygons","python","random"],"latest_commit_sha":null,"homepage":"","language":"Python","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/bast.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}},"created_at":"2021-09-24T11:47:18.000Z","updated_at":"2024-11-05T06:54:32.000Z","dependencies_parsed_at":"2022-08-29T10:41:58.963Z","dependency_job_id":null,"html_url":"https://github.com/bast/polygenerator","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/bast/polygenerator","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bast%2Fpolygenerator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bast%2Fpolygenerator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bast%2Fpolygenerator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bast%2Fpolygenerator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bast","download_url":"https://codeload.github.com/bast/polygenerator/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bast%2Fpolygenerator/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":264419452,"owners_count":23605197,"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":["polygons","python","random"],"created_at":"2024-10-14T08:51:42.609Z","updated_at":"2025-07-09T08:04:24.617Z","avatar_url":"https://github.com/bast.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![license](https://img.shields.io/badge/license-%20MIT-blue.svg)](LICENSE)\n[![test status](https://github.com/bast/polygenerator/workflows/Test/badge.svg)](https://github.com/bast/polygenerator/actions)\n[![link to PyPI](https://badge.fury.io/py/polygenerator.svg)](https://badge.fury.io/py/polygenerator)\n\n\n# polygenerator\n\nGenerates random simple polygons. This can be useful to test computational\ngeometry algorithms.\n\n\n## Installation\n\n```\n$ pip install polygenerator\n```\n\n\n## API\n\nThere are 3 functions and each returns a list of (x, y) tuples:\n- `random_convex_polygon(num_points)`\n- `random_polygon(num_points)`\n- `random_star_shaped_polygon(num_points)`\n\nAll polygons are generated to be **counterclockwise**. You can reverse the order\noutside if you need the points in clockwise order.\n\nThe generated polygon is made to fit the bounding box (0.0, 0.0) ... (1.0, 1.0)\nand you can then scale and translate it to where you need it.\n\n\n## Example\n\n```python\nfrom polygenerator import (\n    random_polygon,\n    random_star_shaped_polygon,\n    random_convex_polygon,\n)\n\nfrom plot import plot_polygon\n\n# this is just so that you can reproduce the same results\nimport random\nrandom.seed(5)\n\n\npolygon = random_polygon(num_points=20)\n\nprint(polygon)\n# [(0.752691110661913, 0.948158571633034), (0.7790276993942304, 0.05437135270534656), ..., (0.633385213909564, 0.7365967958574935)]\n\nplot_polygon(polygon, \"random_polygon.png\")\n```\n![random polygon](img/random_polygon.png)\n\n```python\npolygon = random_star_shaped_polygon(num_points=20)\nplot_polygon(polygon, \"random_star_shaped_polygon.png\")\n```\n![random star shaped polygon](img/random_star_shaped_polygon.png)\n\n```python\npolygon = random_convex_polygon(num_points=20)\nplot_polygon(polygon, \"random_convex_polygon.png\")\n```\n![random convex polygon](img/random_convex_polygon.png)\n\n\n## Notes\n\n- For the generation of a concave/general polygon, algorithms with better\n  scaling exist but this was good enough for me since for testing I did not\n  need polygons with more than 100 points. Improvements welcome.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbast%2Fpolygenerator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbast%2Fpolygenerator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbast%2Fpolygenerator/lists"}