{"id":46743266,"url":"https://github.com/Anaxarchus/odin_clipper2","last_synced_at":"2026-03-23T19:01:18.486Z","repository":{"id":341459376,"uuid":"1169613253","full_name":"Anaxarchus/odin_clipper2","owner":"Anaxarchus","description":"Odin bindings for the C++ polygon clipping library: Clipper2.","archived":false,"fork":false,"pushed_at":"2026-03-01T20:33:38.000Z","size":191,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-03-01T22:34:59.913Z","etag":null,"topics":["odin","odin-lang","polygon","polygon-boolean","polygon-clipping","polygon-offsetting","polygons"],"latest_commit_sha":null,"homepage":"","language":"Odin","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsl-1.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Anaxarchus.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,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-03-01T00:03:12.000Z","updated_at":"2026-03-01T20:33:41.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/Anaxarchus/odin_clipper2","commit_stats":null,"previous_names":["anaxarchus/odin_clipper2"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/Anaxarchus/odin_clipper2","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Anaxarchus%2Fodin_clipper2","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Anaxarchus%2Fodin_clipper2/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Anaxarchus%2Fodin_clipper2/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Anaxarchus%2Fodin_clipper2/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Anaxarchus","download_url":"https://codeload.github.com/Anaxarchus/odin_clipper2/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Anaxarchus%2Fodin_clipper2/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30865211,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-23T18:35:51.002Z","status":"ssl_error","status_checked_at":"2026-03-23T18:35:42.451Z","response_time":59,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["odin","odin-lang","polygon","polygon-boolean","polygon-clipping","polygon-offsetting","polygons"],"created_at":"2026-03-09T18:00:46.814Z","updated_at":"2026-03-23T19:01:18.465Z","avatar_url":"https://github.com/Anaxarchus.png","language":"Odin","readme":"# Clipper2 bindings for Odin\nThese are a work in progress; however, most features work.  \nThe only features which are missing are the following Clipper methods:\n- `BooleanOp_PolyTree64`  \n- `BooleanOp_PolyTreeD`  \nThese are missing because I have not yet written the marshalling/unmarshalling methods for handling poly paths. I have no plans currently to work on these features.\nI have not included binaries for Windows or Linux. To add them, you'll need to build them from source. This is fairly straightforward:\n1. Clone Clipper2 [here](https://github.com/AngusJohnson/Clipper2).  \n2. Run CMake to build the library.  \n3. Add the binary to `bin/\u003cWindows|Linux\u003e` and it should work.\n\n## Usage\n\nAll procedures accept either `[2]i64` or `[2]f64` point types and are overloaded under a common name where both variants exist.\n\n### Boolean Operations\n\nUnion, intersection, difference, and XOR between two sets of polygons.\n\n```odin\nsubjects := [][][2]i64{\n    {{0, 0}, {100, 0}, {100, 100}, {0, 100}},\n}\nclips := [][][2]i64{\n    {{50, 50}, {150, 50}, {150, 150}, {50, 150}},\n}\n\n// Intersection\nresult := clipper2.boolean_op_i64(.Intersection, .NonZero, subjects, clips)\ndefer for path in result do delete(path)\ndefer delete(result)\n\n// Union\nresult = clipper2.boolean_op_i64(.Union, .NonZero, subjects, clips)\n\n// Difference\nresult = clipper2.boolean_op_i64(.Difference, .NonZero, subjects, clips)\n```\n\n### Offsetting (Inflating / Deflating)\n\nExpand or shrink a polygon by a given delta. Positive delta inflates, negative deflates.\n\n```odin\npolygon := [][2]f64{{0, 0}, {100, 0}, {100, 100}, {0, 100}}\n\n// Inflate by 10 units with round joins\ninflated := clipper2.offset(polygon, 10.0, .Round, .Polygon)\ndefer for path in inflated do delete(path)\ndefer delete(inflated)\n\n// Deflate by 10 units with miter joins\ndeflated := clipper2.offset(polygon, -10.0, .Miter, .Polygon)\n```\n\nTo offset multiple polygons at once, pass a `[][][2]f64` slice:\n\n```odin\npolygons := [][][2]f64{\n    {{0, 0}, {100, 0}, {100, 100}, {0, 100}},\n    {{200, 200}, {300, 200}, {300, 300}, {200, 300}},\n}\n\nresult := clipper2.offset(polygons, 5.0, .Square, .Polygon)\n```\n\n### Triangulation\n\nDecompose polygons into triangles. Optionally use Delaunay triangulation.\n\n```odin\npolygons := [][][2]i64{\n    {{0, 0}, {200, 0}, {200, 200}, {0, 200}},\n}\n\ntriangles := clipper2.triangulate(polygons)\ndefer for tri in triangles do delete(tri)\ndefer delete(triangles)\n\n// Each resulting path is a triangle (3 points)\nfor tri in triangles {\n    fmt.println(tri) // e.g. {[0,0], [200,0], [200,200]}\n}\n\n// Delaunay triangulation\ntriangles_delaunay := clipper2.triangulate(polygons, use_delaunay = true)\n```\n\n### Minkowski Sum and Difference\n\n```odin\npattern := [][2]i64{{-5, 0}, {0, 5}, {5, 0}, {0, -5}} // diamond\npath    := [][2]i64{{0, 0}, {100, 0}, {100, 100}}\n\nsum  := clipper2.minkowski_sum(pattern, path, is_closed = false)\ndiff := clipper2.minkowski_difference(pattern, path, is_closed = false)\n\ndefer for p in sum do delete(p)\ndefer delete(sum)\n```\n\n## Building Clipper2\nThe following commands will create a build directory at `CPP/build`, configure CMake, and build the project.\n### Setting up the build directory\n```bash\ncd CPP\nmkdir -p build\ncd build\n```\n### Native\n```bash\ncmake .. \\\n  -DCMAKE_BUILD_TYPE=Release \\\n  -DCLIPPER2_EXAMPLES=OFF \\\n  -DCLIPPER2_TESTS=OFF \\\n  -DCLIPPER2_UTILS=OFF\ncmake --build . --config Release\n```\n### WASM\nIf for some reason you need to rebuild the WASM binary from source, you can clone my fork [here](https://github.com/Anaxarchus/Clipper2), which has been modified to build for WASM. There is a switch for WASM in the CMake.\nInstall and activate Emscripten so that `emcmake` is available in your shell.\n#### WASM Archive (Emscripten)\n```bash\nemcmake cmake .. \\\n  -DCMAKE_BUILD_TYPE=Release \\\n  -DCLIPPER2_EXAMPLES=OFF \\\n  -DCLIPPER2_TESTS=OFF\ncmake --build .\n```\n#### WASM Module (Emscripten)\nTo produce a standalone WebAssembly module instead:\n```bash\nemcmake cmake .. \\\n  -DCMAKE_BUILD_TYPE=Release \\\n  -DCLIPPER2_WASM_ARCHIVE=OFF \\\n  -DCLIPPER2_EXAMPLES=OFF \\\n  -DCLIPPER2_TESTS=OFF\ncmake --build .\n```\n","funding_links":[],"categories":["Bindings"],"sub_categories":["Vendor"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FAnaxarchus%2Fodin_clipper2","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FAnaxarchus%2Fodin_clipper2","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FAnaxarchus%2Fodin_clipper2/lists"}