Skip to content

A simple implementation of marching squares in computer graphics

Notifications You must be signed in to change notification settings

amirhossein-razlighi/Marching_Squares

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Marching Squares

Description

This is a simple implementation of marching squares algorithm in Computer Graphics, in python. The code main.py creates 2d terrains using the algorithm and shows them as a plot. The code contains different value systems for nodes of squares (binary as 0 and 1, and float as 0.0 to 1.0) and different ways of assigning them values (using simple uniform random generator, or using different kinds of noise). The code also contains a simple implementation of some noise generators.

Usage

python3 -m venv ./venv
source ./venv/bin/activate
pip install -r requirements.txt

and then:

python3 main.py

Example outputs:

These are sample outputs for binary values of square nodes and using uniform random generator for assigning values to nodes:

Example output 1 Example output 2 Example output 3

You can run the code with --use_float argument to use float values for the points. Right now, we use random values between -1 and 1.

python3 main.py --use_float

and the result will look like:

Example output 4

About

A simple implementation of marching squares in computer graphics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages