{"id":16197636,"url":"https://github.com/jcash/defold-voronoi","last_synced_at":"2025-03-19T05:30:30.021Z","repository":{"id":151219575,"uuid":"83122810","full_name":"JCash/defold-voronoi","owner":"JCash","description":"A small extension for Defold to add 2D voronoi functionality","archived":false,"fork":false,"pushed_at":"2023-05-08T20:40:53.000Z","size":226,"stargazers_count":11,"open_issues_count":1,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-17T03:51:21.662Z","etag":null,"topics":["defold","defold-library"],"latest_commit_sha":null,"homepage":null,"language":"C","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/JCash.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}},"created_at":"2017-02-25T09:59:48.000Z","updated_at":"2025-02-12T13:53:58.000Z","dependencies_parsed_at":"2023-06-26T09:31:02.878Z","dependency_job_id":null,"html_url":"https://github.com/JCash/defold-voronoi","commit_stats":{"total_commits":11,"total_committers":3,"mean_commits":"3.6666666666666665","dds":0.2727272727272727,"last_synced_commit":"f74e89e5b597d36cf0862d35ccbe179a3428cc90"},"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JCash%2Fdefold-voronoi","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JCash%2Fdefold-voronoi/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JCash%2Fdefold-voronoi/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JCash%2Fdefold-voronoi/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/JCash","download_url":"https://codeload.github.com/JCash/defold-voronoi/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244364546,"owners_count":20441457,"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":["defold","defold-library"],"created_at":"2024-10-10T09:08:05.452Z","updated_at":"2025-03-19T05:30:30.015Z","avatar_url":"https://github.com/JCash.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# defold-voronoi\n\nA small extension for Defold to add 2D voronoi functionality\n\nUses the C/C++ library [jc_voronoi](https://github.com/JCash/voronoi) which\nis a fast C implementation for creating 2D Voronoi diagrams from a point set.\n\nUses [Fortune's sweep algorithm.](https://en.wikipedia.org/wiki/Fortune%27s_algorithm)\n\nTested on iOS, OSX and Windows (should work fine on Android too)\n\nScreenshot:\n\n![50 points](main/images/screenshot.png)\n\n\n# Lua API\n\nThis extension adds a Lua module named `voronoi`\n\n## voronoi.create(width, height)\n\nCreates, and returns, a voronoi diagram context.\n\n    self.diagram = voronoi.create(800, 600)\n\n## voronoi.destroy(diagram)\n\nDestroys a diagram context\n\n## voronoi.generate(diagram, points)\n\nGenerates a 2D voronoi diagram from a set of 2D points\nThe `points` variable is a table with numbers: `{ x1, y1, x2, y2, ... }`\n\n    local points = { 1.0, 1.5, 2.3, 3.1 }\n    voronoi.generate(self.diagram, points } \n\nAfter generating the diagram, the results can be retrieved by `voronoi.get_site()`\n\n## voronoi.get_num_sites(diagram)\n\nReturns the number of valid sites. Note that some sites might\nhave been removed since they were duplicates.\n\n## voronoi.get_site(diagram, index)\n\nGets a site and it's information.\n\n- `index` - the index of the site in the original set of points\n\n- `x` - the x value of the site's position\n\n- `y` - the y value of the site's position\n\n- `area` - the area of the voronoi cell\n\n- `edges` - a list of the neighboring edges, where each edge is a table\nand contains:\n\n-- '1' = `{ x, y }` - The first point of the edge\n\n-- '2' = `{ x, y }` - The second point of the edge\n\n-- 'neighbor' - the index of the neighbor in the original set of points\n\n\nNote that the edges are sorted, and are always rotated counter clockwise around the current site.\n\nHere is an example of how to iterate the generated diagram:\n\n    local num_sites = voronoi.get_num_sites(self.diagram)\n    for i=1,num_sites do\n        local site = voronoi.get_site(self.diagram, i)\n        for ei, edge in pairs(site.edges) do\n            if edge.neighbor \u003e 0 then\n                ...\n            end\n        end\n    end\n\n## voronoi.get_debug_image(diagram)\n\nGets an rgb image showing the diagram. The image is a buffer with the signature `{hash(\"rgb\"), buffer_VALUE_TYPE_UINT8, 3}`\n\n    self.textureheader = {width=self.width,\n                        height=self.height,\n                        type=resource.TEXTURE_TYPE_2D,\n                        format=resource.TEXTURE_FORMAT_RGB,\n                        num_mip_maps=1 }\n    local path = go.get(\"#sprite\", \"texture0\")\n    local image = voronoi.get_debug_image(self.diagram)\n    resource.set_texture(path, self.textureheader, image)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjcash%2Fdefold-voronoi","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjcash%2Fdefold-voronoi","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjcash%2Fdefold-voronoi/lists"}