{"id":16252998,"url":"https://github.com/neki-dev/gen-biome","last_synced_at":"2025-03-17T07:10:37.876Z","repository":{"id":57677691,"uuid":"482356578","full_name":"neki-dev/gen-biome","owner":"neki-dev","description":"🧩 Procedural generation of 2D maps with distinct biomes","archived":false,"fork":false,"pushed_at":"2024-09-12T22:15:32.000Z","size":918,"stargazers_count":39,"open_issues_count":1,"forks_count":4,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-03-05T04:11:20.862Z","etag":null,"topics":["2d","biome","generation","map","perlin","procedural","terrain","tilemap"],"latest_commit_sha":null,"homepage":"https://gen-biome.neki.guru","language":"TypeScript","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/neki-dev.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":"2022-04-16T20:40:17.000Z","updated_at":"2025-02-15T06:12:06.000Z","dependencies_parsed_at":"2024-07-14T17:15:24.351Z","dependency_job_id":"f2985bfa-5dfa-4df1-b3aa-b07eb7bd99af","html_url":"https://github.com/neki-dev/gen-biome","commit_stats":{"total_commits":59,"total_committers":2,"mean_commits":29.5,"dds":0.05084745762711862,"last_synced_commit":"accbbf5068f1812daf71fb4629525152fc834e47"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/neki-dev%2Fgen-biome","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/neki-dev%2Fgen-biome/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/neki-dev%2Fgen-biome/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/neki-dev%2Fgen-biome/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/neki-dev","download_url":"https://codeload.github.com/neki-dev/gen-biome/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243989576,"owners_count":20379648,"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":["2d","biome","generation","map","perlin","procedural","terrain","tilemap"],"created_at":"2024-10-10T15:15:38.599Z","updated_at":"2025-03-17T07:10:37.854Z","avatar_url":"https://github.com/neki-dev.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"## ![Gen Biome](./docs/logotype-s.png)\n[![Version](https://badgen.net/npm/v/gen-biome)](https://npmjs.com/package/gen-biome)\n[![Small size](https://img.badgesize.io/neki-dev/gen-biome/master/dist/index.js)](https://github.com/neki-dev/gen-biome/blob/master/dist/index.js)\n[![Build](https://github.com/neki-dev/gen-biome/actions/workflows/deploy.yml/badge.svg)](https://github.com/neki-dev/gen-biome/actions/workflows/deploy.yml)\n\nProcedural generation of 2D maps with distinct biomes\n\n.\n\n[Demo](https://gen-biome.neki.guru/)\n\nDocumentation\n\n* [Install](https://github.com/neki-dev/gen-biome?tab=readme-ov-file#install)\n* [Generator](https://github.com/neki-dev/gen-biome?tab=readme-ov-file#generator)\n* [Biomes](https://github.com/neki-dev/gen-biome?tab=readme-ov-file#biomes)\n* [Generation](https://github.com/neki-dev/gen-biome?tab=readme-ov-file#generation)\n* [World](https://github.com/neki-dev/gen-biome?tab=readme-ov-file#world)\n* [Example](https://github.com/neki-dev/gen-biome?tab=readme-ov-file#example)\n\n.\n\n## Install\n\n```sh\nnpm i gen-biome\n```\n\n.\n\n## Generator\n### Create world generator\n```ts\nnew WorldGenerator\u003cT\u003e(config: WorldConfig)\n```\n[`config`] - _World config_\n\n| Prop | Description | Default | Range |\n| ---- | ----------- | ------- | ----- |\n| width | Map width |  |  |\n| height | Map height |  |  |\n| frequencyChange | Frequency of biomes change | 0.3 | 0.0 - 1.0 |\n| borderSmoothness | Smoothness of biomes borders | 0.5 | 0.0 - 1.0 |\n| heightRedistribution | Redistribution of biomes height | 1.0 | 0.5 - 1.5 |\n| heightAveraging | Averaging of biomes height | true |  |\n| falloff | Scale of falloff area | 0.0 |  |\n\n.\n\n## Biomes\n### Add biome\n```ts\ngenerator.addBiome(\n  config: WorldBiomeConfig, \n  data: T,\n): WorldBiome\u003cT\u003e\n```\n[`config`] - _Biome config_\n \n| Prop | Description | Default |\n| ---- | ----------- | ------- | \n| lowerBound | Lower biome bound | 0.0 |\n| upperBound | Upper biome bound | 1.0 |\n\n[`data`] - _Biome data that will be stored in the world matrix_\n\n### Get current biomes\n```ts\ngenerator.getBiomes(): WorldBiome\u003cT\u003e[]\n```\n\n### Clear all biomes\n```ts\ngenerator.clearBiomes()\n```\n\n.\n\n## Generation\n### Generate world\n```ts\ngenerator.generate(\n  params?: WorldGenerationParams,\n): World\u003cT\u003e\n```\n[`params`] - _Generation params_ (optional)\n \n| Prop | Description | Default |\n| ---- | ----------- | ------- | \n| seed | Generation seed | (autogenerated) |\n| seedSize | Size of seed array | 512 |\n| offsetX | Generation offset X | 0 |\n| offsetY | Generation offset Y | 0 |\n\n.\n\n## World\n### Get matrix of biomes data\n```ts\nworld.getMatrix(): T[][]\n```\n\n### Each all positions\n```ts\nworld.each(\n  callback: (position: WorldPoint, data: T) =\u003e void,\n): void\n```\n[`callback`] - _Callback with position and biome stored data_\n\n### Get biome data at position\n```ts\nworld.getAt(\n  position: WorldPoint,\n): T | null\n```\n[`position`] - _Position at matrix_\n\n### Replace biome data at position\n```ts\nworld.replaceAt(\n  position: WorldPoint, \n  data: T,\n): void\n```\n[`position`] - _Position at matrix_\n\n[`data`] - _New biome stored data_\n\n### Get current world generation seed\n```ts\nworld.seed: number[]\n```\n\n### Get world width\n```ts\nworld.width: number\n```\n\n### Get world height\n```ts\nworld.height: number\n```\n\n.\n\n## Example\n\n```ts\nconst TILE_SIZE = 2;\nconst BIOMES = [\n  { // WATER\n    params: { lowerBound: 0.0, upperBound: 0.2 },\n    data: { color: 'blue' },\n  },\n  { // GRASS\n    params: { lowerBound: 0.2, upperBound: 0.7 },\n    data: { color: 'green' },\n  },\n  { // MOUNTS\n    params: { lowerBound: 0.7 },\n    data: { color: 'gray' },\n  },\n];\n\nconst generator = new WorldGenerator({\n  width: 100,\n  height: 100,\n});\n\nfor (const { params, data } of BIOMES) {\n  generator.addBiome(params, data);\n}\n\nconst world = generator.generate();\n\nworld.each((position, biome) =\u003e {\n  const tileX = position.x * TILE_SIZE;\n  const tileY = position.y * TILE_SIZE;\n\n  ctx.fillStyle = biome.color;\n  ctx.fillRect(tileX, tileY, TILE_SIZE, TILE_SIZE);\n});\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fneki-dev%2Fgen-biome","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fneki-dev%2Fgen-biome","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fneki-dev%2Fgen-biome/lists"}