Skip to content

Instantly share code, notes, and snippets.

@Psycojoker
Created March 13, 2018 19:07
Show Gist options
  • Save Psycojoker/e28ead7bd4c5c9899113528b22c42c94 to your computer and use it in GitHub Desktop.
Save Psycojoker/e28ead7bd4c5c9899113528b22c42c94 to your computer and use it in GitHub Desktop.
import noise
width = 600
height = 300
freq = 160.0
image = Image.new("RGBA", (width, height))
pixels = image.load()
for i in range(0, width):
for j in range(0, height):
number = int((noise.snoise2(i / freq, j / freq, octaves=10) * 127) + 128)
color = (number, number, number)
if 0 <= number < 110: # deep water
color = (0, 0, 255)
elif 110 <= number < 130: # water
color = (64, 188, 255)
elif 130 <= number < 140: # beatch
color = (235, 197, 158)
elif 140 <= number < 160: # grass
color = (0, 197, 0)
elif 160 <= number < 175: # forest
color = (0, 154, 0)
elif 175 <= number < 195: # montains
color = (172, 108, 43)
else: # snow on montains
color = (229, 254, 299)
pixels[(i, j)] = color
image
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment