{"id":21324088,"url":"https://github.com/mcejp/tilevision","last_synced_at":"2025-03-15T23:21:52.695Z","repository":{"id":247260961,"uuid":"825392846","full_name":"mcejp/tilevision","owner":"mcejp","description":"Real-time streamed tile-based visualisation","archived":false,"fork":false,"pushed_at":"2024-08-01T19:37:37.000Z","size":230,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-09T01:29:41.427Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mcejp.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":"2024-07-07T16:37:47.000Z","updated_at":"2024-08-01T19:37:40.000Z","dependencies_parsed_at":"2024-11-21T20:39:53.183Z","dependency_job_id":null,"html_url":"https://github.com/mcejp/tilevision","commit_stats":null,"previous_names":["mcejp/tilevision"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mcejp%2Ftilevision","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mcejp%2Ftilevision/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mcejp%2Ftilevision/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mcejp%2Ftilevision/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mcejp","download_url":"https://codeload.github.com/mcejp/tilevision/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243802942,"owners_count":20350316,"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-21T20:28:38.716Z","updated_at":"2025-03-15T23:21:52.670Z","avatar_url":"https://github.com/mcejp.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"Usage example:\n\n    ./websocketd \\\n        --address=localhost \\\n        --port=4000 \\\n        --staticdir=static \\\n        python -u -m my_kernel\n\nExample kernel:\n\n```python\nfrom tilevision.matplotlib_util import bg_from_heightmap\nfrom tilevision.path_util import circle, line, line_polar, polyline, rectangle_centered, star, triangle\nfrom tilevision.tilevision import Label, Path\n\n\nlogger = logging.getLogger(__name__)\n\n\nclass MyKernel:\n    # OPTIONAL\n    @staticmethod\n    def register_args(parser):\n        parser.add_argument(\"--version\", required=True, type=int, choices=[2018, 2021])\n\n    def __init__(self, args, tv):\n        tv.send_hello(w=world_size[0],\n                      h=world_size[1],\n                      bg=bg_from_heightmap(world_height, vmin=-200, vmax=1000))\n\n    @property\n    def name(self):\n        return f\"Settlements 2021\"\n\n    def report(self, f):\n        for settlement in self._settlements:\n            f.write(f'~settlement:~ `{settlement.name:31s}`\\n')\n            f.write(f'~houses:~     `{len(settlement.houses)    :4d}` | ~houses needed:~    `{housing_need:3d}`\\n')\n            f.write(f'~population:~ `{len(settlement.people)    :4d}` | ~food consumption:~ `{yearly_food_consumption:3d}`/yr\\n')\n            f.write(f'~farmland:~   `{farmable_tiles            :4d}` | ~food yield:~       `{yearly_farm_yield:3d}`/yr\\n')\n            f.write(f'~food:~       `{settlement.food_reserves:4.0f}` | ~net gain:~         `{yearly_farm_yield - yearly_food_consumption:3d}`/yr\\n')\n            f.write(\"\\n\")\n\n    def step(self, tv):\n        labels = []\n        paths = []\n\n        for x1, y1, x2, y2 in self._road_network['road_segments']:\n            paths.append(Path(line(x1, y1, x2, y2),\n                              linedash=[0.4, 0.15],\n                              linewidth=0.2,\n                              stroke=\"rgba(255,255,255,0.8)\"))\n\n        for x, y in np.ndindex(self._world_height.shape):\n            def draw_field(x, y):\n                return \" \".join(circle(x + xx * 0.5 - 0.25, y + yy * 0.5 - 0.25, 0.1) for xx, yy in np.ndindex((2, 2)))\n\n            def draw_house(x, y):\n                return polyline([(x - 0.3, y - 0.4),\n                                 (x + 0.3, y - 0.4),\n                                 (x + 0.3, y),\n                                 (x + 0.5, y),\n                                 (x,       y + 0.5),\n                                 (x - 0.5, y),\n                                 (x - 0.3, y),\n                                 ])\n\n            if self._building_faction[x, y] != 0:\n                paths.append(Path(draw_house(x, y), fill=\"rgba(255,255,255,0.6)\"))\n            if farm_faction[x, y] != 0:\n                paths.append(Path(draw_field(x, y), linewidth=0.1, fill=\"rgba(255,255,255,0.8)\"))\n            elif self._farmable[x, y] != 0:\n                paths.append(Path(rectangle_centered(x, y, 0.45, 0.45), linewidth=0.1, stroke=\"rgba(255,255,255,0.25)\"))\n\n        for settlement in self._settlements:\n            x = settlement.x\n            y = settlement.y\n            labels.append(Label(x + 0.5, y - 1.5,\n                                f'{settlement.name} ({len(settlement.people)})',\n                                color=\"#ffffff\", fontsize=1.5))\n            paths.append(Path(star(5, r1=0.7, r2=0.3, x=x, y=y), fill=\"#ffffff\"))\n\n        tv.send_annotations(labels, paths)\n\n\nif __name__ == \"__main__\":\n    logging.basicConfig(level=logging.INFO)\n\n    from tilevision.runner import run_kernel\n    run_kernel(MyKernel)\n\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmcejp%2Ftilevision","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmcejp%2Ftilevision","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmcejp%2Ftilevision/lists"}