Browse Source

added positions

oloturia 1 year ago
parent
commit
dfec3a7918
2 changed files with 28 additions and 24 deletions
  1. 24 19
      Layers/colora.py
  2. 4 5
      lands.csv

+ 24 - 19
Layers/colora.py

@@ -2,6 +2,8 @@ from PIL import Image, ImageMath
 import numpy
 
 def colourLandSea(to_colour):
+	colours_ref = {"blue":(0,0,230),"red":(230,0,0),"green":(0,230,0),"yellow":(230,230,0),"violet":(230,0,230),"gray":(80,80,80)}
+
 	im = Image.open(to_colour["country"]+".png")
 	im = im.convert("RGBA")
 
@@ -9,30 +11,33 @@ def colourLandSea(to_colour):
 	r,g,b,a = data.T
 	
 	land = (r == 255) & (g == 255) & (b == 255)
-	data[..., :-1][land.T] = to_colour["colour"]
+	data[..., :-1][land.T] = colours_ref[to_colour["colour"]]
 
 	im_coloured = Image.fromarray(data)
+	if to_colour["land"]:
+		token = Image.open("../army.png")
+		position = (162,175)
+	else:
+		token = Image.open("../fleet.png")
+		position = (236,415)	
+	im_coloured.paste(token,position,token)
+	
 	return im_coloured
 
-red = (230,0,0)
-green = (0,230,0)
-blue = (0,0,230)
-yellow = (230,230,0)
-violet = (230,0,230)
-gray = (80,80,80)
+if __name__ == "__main__":
 
-start_sit = [{"country":"EDI","colour":blue},{"country":"TYS","colour":yellow}]
-countries = list()
-for start_country in start_sit:
-	countries.append(colourLandSea(start_country))
+	start_sit = [{"country":"EDI","colour":"blue","land":True},{"country":"TYS","colour":"yellow","land":False}]
+	countries = list()
+	for start_country in start_sit:
+		countries.append(colourLandSea(start_country))
 
-board = Image.open("map.png")
-text = Image.open("text_shaded.png")
+	board = Image.open("map.png")
+	text = Image.open("text_shaded.png")
 
-board = board.convert("RGBA")
-text = text.convert("RGBA")
+	board = board.convert("RGBA")
+	text = text.convert("RGBA")
 
-for country in countries:
-	board.paste(country,(0,0),country)
-board.paste(text,(0,0),text)
-board.show()
+	for country in countries:
+		board.paste(country,(0,0),country)
+	board.paste(text,(0,0),text)
+	board.show()

+ 4 - 5
lands.csv

@@ -14,12 +14,11 @@ Mid-Atlantic Ocean,MAO
 North Atlantic Ocean,NAO
 North Sea,NTH
 Skagerrak,SKA
-Tyrrhenian Sea,TYS
+Tyrrhenian Sea,TYS,234,415
 Western Mediterranean,WMS
-,
-Albania,ALB
-Ankara,ANK
-Apulia,APU
+Albania,ALB,323,418
+Ankara,ANK,480,404
+Apulia,APU,207,405
 Armenia,ARM
 Belgium,BEL
 Berlin,BER