Convert Figma logo to code with AI

mewo2 logoterrain

Fantasy map generator

3,034
355
3,034
1

Top Related Projects

World generator using simulation of plates, rain shadow, erosion, etc.

10,597

A simple Minecraft clone written in C using modern OpenGL (shaders).

Quick Overview

Terrain is a JavaScript library for generating realistic-looking terrain maps using various noise algorithms and rendering techniques. It provides a set of tools for creating and manipulating heightmaps, which can be used to generate 3D terrain models or 2D map visualizations.

Pros

  • Offers a variety of terrain generation algorithms, including Perlin noise, Simplex noise, and Diamond-Square
  • Provides customizable rendering options for creating visually appealing maps
  • Supports both 2D and 3D terrain generation
  • Lightweight and easy to integrate into web-based projects

Cons

  • Limited documentation and examples, which may make it challenging for beginners to get started
  • Not actively maintained, with the last update being several years ago
  • Lacks advanced features like erosion simulation or biome generation
  • May require additional libraries or tools for more complex terrain visualization

Code Examples

  1. Generating a basic heightmap using Perlin noise:
const terrain = new Terrain(256, 256);
terrain.generate('perlin', { octaves: 6, persistence: 0.5 });
const heightmap = terrain.heightmap;
  1. Rendering a 2D terrain map with a custom color scheme:
const renderer = new TerrainRenderer(terrain);
renderer.setColorScheme([
  { height: 0, color: '#0077be' },
  { height: 0.3, color: '#00a86b' },
  { height: 0.7, color: '#c2b280' },
  { height: 1, color: '#ffffff' }
]);
const canvas = renderer.render2D();
document.body.appendChild(canvas);
  1. Applying a terrain filter to smooth the heightmap:
terrain.applyFilter('smooth', { iterations: 3 });

Getting Started

To use Terrain in your project, follow these steps:

  1. Include the Terrain library in your HTML file:

    <script src="path/to/terrain.js"></script>
    
  2. Create a new Terrain instance and generate a heightmap:

    const terrain = new Terrain(512, 512);
    terrain.generate('simplex', { octaves: 8, persistence: 0.5 });
    
  3. Render the terrain using the TerrainRenderer:

    const renderer = new TerrainRenderer(terrain);
    const canvas = renderer.render2D();
    document.body.appendChild(canvas);
    

This will create a basic 2D terrain map and add it to your webpage. You can further customize the terrain generation and rendering options to achieve your desired results.

Competitor Comparisons

World generator using simulation of plates, rain shadow, erosion, etc.

Pros of worldengine

  • More comprehensive world generation features, including climate, biomes, and erosion
  • Active development with recent updates and contributions
  • Extensive documentation and examples for users

Cons of worldengine

  • More complex setup and usage compared to terrain
  • Slower generation times due to additional features and calculations
  • Steeper learning curve for new users

Code Comparison

terrain:

def generate_terrain(size, roughness):
    terrain = [[0 for _ in range(size)] for _ in range(size)]
    # ... (diamond-square algorithm implementation)
    return terrain

worldengine:

def generate_world(seed, width, height):
    world = World(seed, width, height, num_plates=10)
    world.set_elevation(0.1, 0.9)
    world.set_ocean_level(0.65)
    world.generate_plates()
    world.generate_terrain()
    return world

The code comparison shows that terrain focuses on a simple terrain generation algorithm, while worldengine offers a more complex world generation process with multiple steps and customizable parameters.

10,597

A simple Minecraft clone written in C using modern OpenGL (shaders).

Pros of Craft

  • More interactive and game-like, allowing real-time exploration of generated terrain
  • Includes additional features like inventory management and block placement/destruction
  • Actively maintained with recent updates and contributions

Cons of Craft

  • More complex codebase, potentially harder to understand and modify
  • Focused on voxel-based terrain rather than heightmap-based terrain generation
  • Requires more system resources to run due to its real-time 3D rendering

Code Comparison

Terrain (Python):

def diamond_square(size, roughness):
    terrain = np.zeros((size, size))
    # ... implementation details ...
    return terrain

Craft (C):

void create_world(int p, int q) {
    int pad = 1;
    for (int dx = -pad; dx < CHUNK_SIZE + pad; dx++) {
        for (int dz = -pad; dz < CHUNK_SIZE + pad; dz++) {
            int x = p * CHUNK_SIZE + dx;
            int z = q * CHUNK_SIZE + dz;
            float f = simplex2(x * 0.01, z * 0.01, 4, 0.5, 2);
            int h = f * 32 + 16;
            int w = 1;
            int t = 12;
            if (h < t) {
                h = t;
                w = 2;
            }
            // ... block placement ...
        }
    }
}

Convert Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README

Fantasy map generator

This is code for generating fantasy maps, using the algorithm behind @unchartedatlas. For more details, see these notes.

Dependencies

This code depends on the following:

Support, licensing, ongoing development

This project is, from my perspective, finished.

The code is available under the MIT license, so you can fork it, improve it, learn from it, build upon it. However, I have no interest in maintaining it as an ongoing open source project, nor in providing support for it. Pull requests will be either ignored or closed.

If you do make something interesting with this code, please do still let me know! I'm sorry that I can't provide any support, but I am still genuinely interested in seeing creative applications of the code.