{"id":13760967,"url":"https://github.com/gorhill/Javascript-Voronoi","last_synced_at":"2025-05-10T11:32:25.929Z","repository":{"id":1501769,"uuid":"1755694","full_name":"gorhill/Javascript-Voronoi","owner":"gorhill","description":"A Javascript implementation of Fortune's algorithm to compute Voronoi cells","archived":false,"fork":false,"pushed_at":"2023-08-25T04:39:19.000Z","size":579,"stargazers_count":1044,"open_issues_count":15,"forks_count":169,"subscribers_count":52,"default_branch":"master","last_synced_at":"2025-04-14T11:13:03.412Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"http://www.raymondhill.net/voronoi/","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/gorhill.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2011-05-16T14:40:26.000Z","updated_at":"2025-04-14T01:24:52.000Z","dependencies_parsed_at":"2022-07-09T11:00:22.859Z","dependency_job_id":"e022187a-841b-406c-bc50-6314085d1570","html_url":"https://github.com/gorhill/Javascript-Voronoi","commit_stats":{"total_commits":105,"total_committers":8,"mean_commits":13.125,"dds":0.2761904761904762,"last_synced_commit":"3fe2165aed14d3424398e04bccb120f68114eab5"},"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gorhill%2FJavascript-Voronoi","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gorhill%2FJavascript-Voronoi/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gorhill%2FJavascript-Voronoi/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gorhill%2FJavascript-Voronoi/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gorhill","download_url":"https://codeload.github.com/gorhill/Javascript-Voronoi/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253410860,"owners_count":21904132,"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-08-03T13:01:29.893Z","updated_at":"2025-05-10T11:32:25.681Z","avatar_url":"https://github.com/gorhill.png","language":"JavaScript","funding_links":[],"categories":["JavaScript","Libraries"],"sub_categories":["To draw using canvas"],"readme":"# Javascript-Voronoi\n\nA Javascript implementation of Steven J. Fortune's algorithm to\nefficiently compute Voronoi diagrams. The Voronoi object's purpose is\nto solely compute a Voronoi diagram, it is completely standalone, with\nno dependency on external code: it contains no rendering code: that is\nleft to the user of the library.\n\n## Core files\n\n* rhill-voronoi-core.js\n\nWhere the Voronoi object is implemented. This is a standalone library, there\nis no dependency.\n\n* rhill-voronoi-core.min.js\n\nThe minimized version (using YUI compressor)\n\n## Demo files\n\n* rhill-voronoi-demo1.html\n* rhill-voronoi-demo2.html\n* rhill-voronoi-demo3.php\n* rhill-voronoi-demo4.html\n* rhill-voronoi-demo5.html\n\nDemo pages to demonstrate usage of the Voronoi object.\n\n* excanvas/*\n\nUsed by demo pages.\n\nExplorerCanvas, giving pre-HTML5 Internet Explorer the ability to make sense\nof HTML5's canvas element. Pulled from http://code.google.com/p/explorercanvas/\n\n* mootools/*\n\nUsed by rhill-voronoi-demo3.php\n\n* Above pages available at http://www.raymondhill.net/voronoi/\n\n\n## Main object: Voronoi\n\nA Javascript object which allows to compute a Voronoi diagram.\nThe Voronoi object doesn't render the resulting Voronoi diagram,\nthe user is responsible for rendering the diagram.\n\n## Usage\n\nRoughly:\n\n``` javascript\nvar voronoi = new Voronoi();\nvar bbox = {xl: 0, xr: 800, yt: 0, yb: 600}; // xl is x-left, xr is x-right, yt is y-top, and yb is y-bottom\nvar sites = [ {x: 200, y: 200}, {x: 50, y: 250}, {x: 400, y: 100} /* , ... */ ];\n\n// a 'vertex' is an object exhibiting 'x' and 'y' properties. The\n// Voronoi object will add a unique 'voronoiId' property to all\n// sites. The 'voronoiId' can be used as a key to lookup the associated cell\n// in diagram.cells.\n\nvar diagram = voronoi.compute(sites, bbox);\n```\n\nThe returned 'diagram' variable is a Javascript object with the\nfollowing properties:\n\n```\ndiagram.vertices\n```\n\nAn array of unordered, unique ```Voronoi.Vertex``` objects making up the\nVoronoi diagram. Each ```Voronoi.Vertex``` object in the list is shared by\nmany ```Voronoi.Edge``` objects.\n\n```\ndiagram.edges\n```\n\nAn array of unordered, unique ```Voronoi.Edge``` objects making up the\nVoronoi diagram. ```Voronoi.Edges``` are defined by two vertices,\n```va``` and ```vb```, which vertices are shared by connected edges. This mean\nthat if you change one vertex belonging to an edge, other connected edges\nwill also be changed.\n\n```\ndiagram.cells\n```\n\nAn array of ```Voronoi.Cell``` objects making up the Voronoi diagram. A\n```Voronoi.Cell``` object might have an empty array of ```halfedges```,\nmeaning no Voronoi cell could be computed for a particular cell.\n\n```\ndiagram.execTime\n```\n\nThe time it took to compute the Voronoi diagram, in milliseconds.\n\nAdded on October 12, 2013: In order to help improve performance,\n`Voronoi.recycle()` has been added to allow the recycling of a returned Voronoi\ndiagram. Usage:\n\n``` javascript\nvar diagram;\n...\n\n// some kind of loop starting here (whether outright or through a timer)\n...\n\nvoronoi.recycle(diagram);\n// diagram.vertices, diagram.edges and diagram.cells can no longer be used!\ndiagram = voronoi.compute(sites, bbox);\n\n// do stuff with content of `diagram`\n...\n```\n\nThis new method helps performance significantly when re-computing a Voronoi\ndiagram, as it saves on memory allocation, and associated garbage collection.\n\n## Public objects\n\n```\nVoronoi\n```\n\nThe ```Voronoi``` object which computes a Voronoi diagram.\n\n```\nVoronoi.Vertex\n```\n\n* ```x```: no explanation required.\n\n* ```y```: no explanation required.\n\n```\nVoronoi.Edge\n```\n\n* ```lSite```: the Voronoi site object at the left of this ```Voronoi.Edge```\nobject. The site object is just a reference to a site in the array of sites\nsupplied by the user when ```Voronoi.compute()``` was called.\n\n* ```rSite```: the Voronoi site object at the right of this ```Voronoi.Edge```\nobject (can be null, when this is a border edge). The site object is just a\nreference to a site in the array of sites supplied by the user when\n```Voronoi.compute()``` was called.\n\n* ```va```: a ```Voronoi.Vertex``` object with an ```x``` and a ```y```\nproperty defining the start point (relative to the Voronoi site on\nthe left) of this ```Voronoi.Edge``` object.\n\n* ```vb```: a ```Voronoi.Vertex``` object with an ```x``` and a ```y```\nproperty defining the end point (relative to Voronoi site on the left)\nof this ```Voronoi.Edge``` object.\n\n```\nVoronoi.Cell\n```\n\n* ```site```: the Voronoi site object associated with the Voronoi cell.\n\n* ```halfedges```: an array of ```Voronoi.Halfedge``` objects, ordered\ncounterclockwise, defining the polygon for this Voronoi cell.\n\n```\nVoronoi.Halfedge\n```\n\n* ```site```: the Voronoi site object owning this ```Voronoi.Halfedge```\nobject.\n\n* ```edge```: a reference to the unique ```Voronoi.Edge``` object underlying\nthis ```Voronoi.Halfedge``` object.\n\n* ```getStartpoint()```: a method returning a ```Voronoi.Vertex``` of the start\npoint of this halfedge. Keep in mind halfedges are always counterclockwise.\n\n* ```getEndpoint()```: a method returning a ```Voronoi.Vertex``` object with\nan ```x``` and a ```y``` property for the end point of this halfedge. Keep in\nmind halfedges are always counterclockwise.\n\n## License\n\nCopyright (c) 2010-2013 Raymond Hill \nhttps://github.com/gorhill/Javascript-Voronoi\n\nLicensed under The MIT License \nhttp://en.wikipedia.org/wiki/MIT_License\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\nall copies 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\nTHE SOFTWARE.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgorhill%2FJavascript-Voronoi","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgorhill%2FJavascript-Voronoi","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgorhill%2FJavascript-Voronoi/lists"}