Bastien Sevajol преди 6 години
родител
ревизия
43eaea355a
променени са 3 файла, в които са добавени 15 реда и са изтрити 3 реда
  1. 1 0
      requirements.txt
  2. 1 0
      setup.py
  3. 13 3
      synergine2_cocos2d/actor.py

+ 1 - 0
requirements.txt Целия файл

15
 six==1.11.0
15
 six==1.11.0
16
 tmx==1.9.1
16
 tmx==1.9.1
17
 pytest-mock==1.6.3
17
 pytest-mock==1.6.3
18
+Pillow==5.0.0

+ 1 - 0
setup.py Целия файл

15
 ]
15
 ]
16
 cocos2d_require = [
16
 cocos2d_require = [
17
     'cocos2d',
17
     'cocos2d',
18
+    'Pillow',
18
 ] + xyz_require
19
 ] + xyz_require
19
 tests_require = [
20
 tests_require = [
20
     'pytest',
21
     'pytest',

+ 13 - 3
synergine2_cocos2d/actor.py Целия файл

5
 import ntpath
5
 import ntpath
6
 
6
 
7
 import pyglet
7
 import pyglet
8
-
8
+from PIL import Image
9
 import cocos
9
 import cocos
10
 from cocos import collision_model
10
 from cocos import collision_model
11
 from cocos import euclid
11
 from cocos import euclid
65
     def build_default_image(self, subject_id: int, base_image_path: str) -> str:
65
     def build_default_image(self, subject_id: int, base_image_path: str) -> str:
66
         cache_dir = self.config.resolve('global.cache_dir_path')
66
         cache_dir = self.config.resolve('global.cache_dir_path')
67
         with open(base_image_path, 'rb') as base_image_file:
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
             final_name = '_'.join([
77
             final_name = '_'.join([
70
                 str(subject_id),
78
                 str(subject_id),
71
                 ntpath.basename(base_image_path),
79
                 ntpath.basename(base_image_path),
72
             ])
80
             ])
73
             final_path = os.path.join(cache_dir, final_name)
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
         return final_path
84
         return final_path
78
 
85
 
86
+    def get_default_appliable_images(self) -> typing.List[Image.Image]:
87
+        return []
88
+
79
     def freeze(self) -> None:
89
     def freeze(self) -> None:
80
         """
90
         """
81
         Set object to freeze mode: No visual modification can be done anymore
91
         Set object to freeze mode: No visual modification can be done anymore