{"id":19775014,"url":"https://github.com/letsar/polygon","last_synced_at":"2025-04-30T19:30:22.472Z","repository":{"id":50193486,"uuid":"517247791","full_name":"letsar/polygon","owner":"letsar","description":"A simple way to draw polygon shapes and to clip them","archived":false,"fork":false,"pushed_at":"2022-07-27T19:48:14.000Z","size":82,"stargazers_count":65,"open_issues_count":1,"forks_count":2,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-06T04:06:45.262Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Dart","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/letsar.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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":"2022-07-24T06:42:52.000Z","updated_at":"2025-02-26T10:45:56.000Z","dependencies_parsed_at":"2022-07-30T19:08:12.670Z","dependency_job_id":null,"html_url":"https://github.com/letsar/polygon","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/letsar%2Fpolygon","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/letsar%2Fpolygon/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/letsar%2Fpolygon/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/letsar%2Fpolygon/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/letsar","download_url":"https://codeload.github.com/letsar/polygon/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251769155,"owners_count":21640847,"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-11-12T05:14:34.276Z","updated_at":"2025-04-30T19:30:22.005Z","avatar_url":"https://github.com/letsar.png","language":"Dart","funding_links":["https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick\u0026hosted_button_id=QTT34M25RDNL6"],"categories":[],"sub_categories":[],"readme":"# polygon\n\nCreate any polygon easily in Flutter with this package!\n\n[![Pub](https://img.shields.io/pub/v/polygon.svg)][pub]\n[![Donate](https://img.shields.io/badge/Donate-PayPal-green.svg)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick\u0026hosted_button_id=QTT34M25RDNL6)\n\nhttps://user-images.githubusercontent.com/9378033/181354646-63d1d8aa-315e-4ef4-8ff3-e5c3a15341bb.mov\n\n## Features\n\n- Create regular convex polygons.\n- Create regular star polygons.\n- Create a polygon border.\n- Clip any widget with a polygon shape.\n\n## Usage\n\n### Create a Polygon\n\nWith this package you can easily create any kind of polygons by just setting its vertices (in a [(-1,-1);(1,1)] rect).\n\n```dart\nconst polygon = Polygon([\n  Offset(0.25, -1),\n  Offset(0, -0.25),\n  Offset(0.5, 0),\n  Offset(-0.25, 1),\n  Offset(0, 0.25),\n  Offset(-0.5, 0),\n]);\n```\n\nYou can then create a path from this polygon by using its `computePath` method.\nFor example you can use it in a `CustomPainter`:\n\n\n```dart\nclass PolygonPainter extends CustomPainter {\n  PolygonPainter(this.polygon);\n\n  final Polygon polygon;\n\n  @override\n  void paint(Canvas canvas, Size size) {\n    canvas.drawPath(\n      polygon.computePath(rect: Offset.zero \u0026 size),\n      Paint()..color = Colors.yellow.shade800,\n    );\n  }\n\n  @override\n  bool shouldRepaint(PolygonPainter oldDelegate) {\n    return oldDelegate.polygon != polygon;\n  }\n}\n```\n\n![sharp](https://user-images.githubusercontent.com/9378033/181352814-e23eacc8-0268-404c-bf8b-35099a74004b.png)\n\nThe `computePath` methods accepts various parameters and you can, for example apply a corner radius to all of the polygon's corners:\n\n![rounded](https://user-images.githubusercontent.com/9378033/181352844-61bf3814-3902-4605-913d-9597b9cf4ff5.png)\n\n### PolygonBorder\n\nThis package has also a dedicated `ShapeBorder` called `PolygonBorder`, so that you can easily apply a color, a border, an image to the polygon or clip anything through `Clip.shape`.\n\n```dart\nDecoratedBox(\n  decoration: ShapeDecoration(\n    shape: PolygonBorder(\n      polygon: polygon,\n      turn: 0.125,\n      radius: 20.0,\n      borderAlign: BorderAlign.outside,\n      side:  BorderSide(\n        width: 4,\n        color: Colors.red,\n      ),\n    ),\n    color: Colors.pink,\n  ),\n  child: const SizedBox(\n    height: 400,\n    width: 400,\n  ),\n),\n```\n\n### Specialized polygons.\n\nThis package comes with two specialized polygons:\nA `RegularConvexPolygon` which can create triangles, tetragons, pentagons, etc.\nA `RegularStarPolygon` which can create various star shapes.\n\nhttps://user-images.githubusercontent.com/9378033/181354589-1c12b68b-2ecc-4ded-a46b-16fe03d6cd57.mov\n\n## Sponsoring\n\nI'm working on my packages on my free-time, but I don't have as much time as I would. If this package or any other package I created is helping you, please consider to sponsor me. By doing so, I will prioritize your issues or your pull-requests before the others. \n\n## Changelog\n\nPlease see the [Changelog][changelog] page to know what's recently changed.\n\n## Contributions\n\nFeel free to contribute to this project.\n\nIf you find a bug or want a feature, but don't know how to fix/implement it, please fill an [issue][issue].  \nIf you fixed a bug or implemented a feature, please send a [pull request][pr].\n\n\u003c!--Links--\u003e\n[pub]: https://pub.dartlang.org/packages/polygon\n[changelog]: https://github.com/letsar/polygon/blob/master/CHANGELOG.md\n[issue]: https://github.com/letsar/polygon/issues\n[pr]: https://github.com/letsar/polygon/pulls\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fletsar%2Fpolygon","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fletsar%2Fpolygon","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fletsar%2Fpolygon/lists"}