Skip to content

Commit

Permalink
updates
Browse files Browse the repository at this point in the history
  • Loading branch information
blurrydude committed May 25, 2022
1 parent cb27118 commit fd818cd
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 0 deletions.
Binary file added Copenhagen.ttf
Binary file not shown.
Binary file added ToThePointRegular.ttf
Binary file not shown.
42 changes: 42 additions & 0 deletions sandy_maps.py
Original file line number Diff line number Diff line change
Expand Up @@ -420,6 +420,7 @@ def __init__(self, width, height):
self.territories = []

def to_image(self):
myFont = ImageFont.truetype('ToThePointRegular.ttf', 48)
print("to_image")
img = Image.new(mode="RGB", size=(self.width, self.height))
for y in range(self.height):
Expand All @@ -444,15 +445,56 @@ def to_image(self):
img.putpixel((x,y), self.noisy_color(color,stddev=10))
else:
img.putpixel((x,y), color)
idraw = ImageDraw.Draw(img)
for y in range(self.height):
for x in range(self.width):
color = (0,0,0)
tile = self.terrain[y][x].t
if tile == "town":
color = (255,128,0)
img.putpixel((x,y), color)
idraw = ImageDraw.Draw(img)
for i in range(len(self.towns)):
x = self.towns[i].x + self.towns[i].size + 2
y = self.towns[i].y - 10
if x > self.width - 200:
x = x - 150
idraw.text((x, y), self.random_town_name(), fill=(0, 0, 0), font=myFont)
return img

def random_town_name(self):
syllable_a = [
"Nu",
"Dew",
"Gri",
"Tei",
"Loe",
"Ji",
"Me",
"Quy"
]
syllable_b = [
"ton",
"yu",
"fer",
"lo",
"ne",
"wa",
"moro",
"bo"
]
syllable_c = [
"ton",
"nia",
"ville",
"to",
"ny",
" Roy",
"moss",
"im"
]
return random.choice(syllable_a) + random.choice(syllable_b) + random.choice(syllable_c)

def noisy_color(self, color, mean=0, stddev=5):
r = self.add_noise(color[0], mean, stddev)
g = self.add_noise(color[1], mean, stddev)
Expand Down

0 comments on commit fd818cd

Please sign in to comment.