-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathicon_loader.py
38 lines (27 loc) · 1.18 KB
/
icon_loader.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import os
from PIL import Image
from utils import resource_path
class IconLoader:
"""Icon loader class
"""
COMPASS_MULT_FACT = 1.35
def __init__(self, path):
"""Initialzer
Args:
path (str): Path to icons folder
"""
self.tc_blue = Image.open(resource_path(os.path.join(path, "towncenter_blue.png")))
self.tc_red = Image.open(resource_path(os.path.join(path, "towncenter_red.png")))
self.tp = Image.open(resource_path(os.path.join(path, "trade.png")))
self.np = Image.open(resource_path(os.path.join(path, "native.png")))
self.gold = Image.open(resource_path(os.path.join(path, "gold.png")))
self.treasure = Image.open(resource_path(os.path.join(path, "treasure.png")))
self.compass = Image.open(resource_path(os.path.join(path, "compass.png")))
def get_compass(self, size):
"""Get resized compass image
Args:
size (int): Image size
Returns:
PIL.Image: Rescaled compass picture
"""
return self.compass.resize((int(size*self.COMPASS_MULT_FACT), int(size*self.COMPASS_MULT_FACT)), Image.ANTIALIAS)