|
@@ -5,7 +5,7 @@ import typing
|
5
|
5
|
import ntpath
|
6
|
6
|
|
7
|
7
|
import pyglet
|
8
|
|
-
|
|
8
|
+from PIL import Image
|
9
|
9
|
import cocos
|
10
|
10
|
from cocos import collision_model
|
11
|
11
|
from cocos import euclid
|
|
@@ -65,17 +65,27 @@ class Actor(AnimatedInterface, cocos.sprite.Sprite):
|
65
|
65
|
def build_default_image(self, subject_id: int, base_image_path: str) -> str:
|
66
|
66
|
cache_dir = self.config.resolve('global.cache_dir_path')
|
67
|
67
|
with open(base_image_path, 'rb') as base_image_file:
|
|
68
|
+ base_image = Image.open(base_image_file)
|
|
69
|
+
|
|
70
|
+ for default_appliable_image in self.get_default_appliable_images():
|
|
71
|
+ base_image.paste(
|
|
72
|
+ default_appliable_image,
|
|
73
|
+ (0, 0),
|
|
74
|
+ default_appliable_image,
|
|
75
|
+ )
|
68
|
76
|
|
69
|
77
|
final_name = '_'.join([
|
70
|
78
|
str(subject_id),
|
71
|
79
|
ntpath.basename(base_image_path),
|
72
|
80
|
])
|
73
|
81
|
final_path = os.path.join(cache_dir, final_name)
|
74
|
|
- with open(final_path, 'wb+') as built_image_file:
|
75
|
|
- built_image_file.write(base_image_file.read())
|
|
82
|
+ base_image.save(final_path)
|
76
|
83
|
|
77
|
84
|
return final_path
|
78
|
85
|
|
|
86
|
+ def get_default_appliable_images(self) -> typing.List[Image.Image]:
|
|
87
|
+ return []
|
|
88
|
+
|
79
|
89
|
def freeze(self) -> None:
|
80
|
90
|
"""
|
81
|
91
|
Set object to freeze mode: No visual modification can be done anymore
|