|
21 | 21 | "is_attribute": True, |
22 | 22 | "is_image": True, |
23 | 23 | "source": ["special_card", "countryball.cached_regime.background"], |
24 | | - "top_left": (0, 0), |
| 24 | + "anchor": (0, 0), |
25 | 25 | "size": (WIDTH, HEIGHT), |
26 | 26 | }, |
27 | 27 | "card_art": { |
28 | 28 | "is_attribute": True, |
29 | 29 | "is_image": True, |
30 | 30 | "source": "countryball.collection_card", |
31 | | - "top_left": (34, 261), |
| 31 | + "anchor": (34, 261), |
32 | 32 | "size": (1359, 731), |
33 | 33 | }, |
34 | 34 | "title": { |
35 | 35 | "is_attribute": True, |
36 | 36 | "is_image": False, |
37 | 37 | "source": ["countryball.short_name", "countryball.country"], |
38 | | - "top_left": (50, 20), |
| 38 | + "anchor": (50, 20), |
39 | 39 | "text_font": "ArsenicaTrial-Extrabold.ttf", |
40 | 40 | "text_font_size": 170, |
41 | 41 | "text_stroke_width": 2, |
|
45 | 45 | "is_attribute": True, |
46 | 46 | "is_image": False, |
47 | 47 | "source": "countryball.capacity_name", |
48 | | - "top_left": (100, 1050), |
| 48 | + "anchor": (100, 1050), |
49 | 49 | "text_line_height": 100, |
50 | 50 | "text_font": "Bobby Jones Soft.otf", |
51 | 51 | "text_wrap": 26, |
|
58 | 58 | "is_attribute": True, |
59 | 59 | "is_image": False, |
60 | 60 | "source": "countryball.capacity_description", |
61 | | - "top_left": (60, "capacity_name"), |
| 61 | + "anchor": (60, "capacity_name"), |
62 | 62 | "text_line_height": 100, |
63 | 63 | "text_font": "OpenSans-Semibold.ttf", |
64 | 64 | "text_wrap": 32, |
|
71 | 71 | "is_attribute": True, |
72 | 72 | "is_image": False, |
73 | 73 | "source": "health", |
74 | | - "top_left": (320, 1670), |
| 74 | + "anchor": (320, 1670), |
75 | 75 | "text_line_height": 100, |
76 | 76 | "text_font": "Bobby Jones Soft.otf", |
77 | 77 | "text_wrap": 32, |
|
84 | 84 | "is_attribute": True, |
85 | 85 | "is_image": False, |
86 | 86 | "source": "attack", |
87 | | - "top_left": (1120, 1670), |
| 87 | + "anchor": (1120, 1670), |
88 | 88 | "text_line_height": 100, |
89 | 89 | "text_font": "Bobby Jones Soft.otf", |
90 | 90 | "text_wrap": 32, |
|
98 | 98 | "is_attribute": False, |
99 | 99 | "is_image": False, |
100 | 100 | "source": "Created by El Lagronn", |
101 | | - "top_left": (30, 1870), |
| 101 | + "anchor": (30, 1870), |
102 | 102 | "text_font": "arial.ttf", |
103 | 103 | "text_line_height": 43, |
104 | 104 | "text_fill": (255, 255, 255, 255), |
|
109 | 109 | "is_attribute": True, |
110 | 110 | "is_image": False, |
111 | 111 | "source": "countryball.credits", |
112 | | - "top_left": (30, "lagg_credits"), |
| 112 | + "anchor": (30, "lagg_credits"), |
113 | 113 | "text_font": "arial.ttf", |
114 | 114 | "text_fill": (255, 255, 255, 255), |
115 | 115 | "text_font_size": 40, |
|
120 | 120 | "is_attribute": True, |
121 | 121 | "is_image": False, |
122 | 122 | "source": "specialcard.credits", |
123 | | - "top_left": (1398, 1870), |
| 123 | + "anchor": (1398, 1870), |
124 | 124 | "text_font": "arial.ttf", |
125 | 125 | "text_fill": (255, 255, 255, 255), |
126 | 126 | "text_font_size": 40, |
@@ -155,7 +155,7 @@ class TemplateLayer(NamedTuple): |
155 | 155 | # Otherwise its a string |
156 | 156 | is_image: bool |
157 | 157 | source: list[str] | str |
158 | | - top_left: tuple[int | str, int | str] |
| 158 | + anchor: tuple[int | str, int | str] |
159 | 159 | size: tuple[int, int] = (0, 0) |
160 | 160 |
|
161 | 161 | # Template string with $data to-be-replaced by the data |
@@ -191,17 +191,18 @@ def draw_layer( |
191 | 191 | prior_layer_info: dict[str, LayerInfo], |
192 | 192 | name: str, |
193 | 193 | ): |
194 | | - if isinstance(layer.top_left[0], int): |
195 | | - startx = layer.top_left[0] |
| 194 | + if isinstance(layer.anchor[0], int): |
| 195 | + startx = layer.anchor[0] |
196 | 196 | else: |
197 | | - startx = prior_layer_info[layer.top_left[0]].finished_coords[0] |
| 197 | + startx = prior_layer_info[layer.anchor[0]].finished_coords[0] |
198 | 198 |
|
199 | | - if isinstance(layer.top_left[1], int): |
200 | | - starty = layer.top_left[1] |
| 199 | + if isinstance(layer.anchor[1], int): |
| 200 | + starty = layer.anchor[1] |
201 | 201 | else: |
202 | | - starty = prior_layer_info[layer.top_left[1]].finished_coords[1] |
| 202 | + starty = prior_layer_info[layer.anchor[1]].finished_coords[1] |
203 | 203 |
|
204 | 204 | start_coords = (startx, starty) |
| 205 | + end_coords = (startx + layer.size[0], starty + layer.size[1]) |
205 | 206 | draw = ImageDraw.Draw(image) |
206 | 207 |
|
207 | 208 | data: str | None |
@@ -238,12 +239,7 @@ def draw_layer( |
238 | 239 | layer_image = ImageOps.fit(layer_image, layer.size) |
239 | 240 | image.paste(layer_image, start_coords, mask=layer_image) |
240 | 241 |
|
241 | | - prior_layer_info[name] = LayerInfo( |
242 | | - finished_coords=( |
243 | | - start_coords[0] + layer.size[0], |
244 | | - start_coords[1] + layer.size[1], |
245 | | - ) |
246 | | - ) |
| 242 | + prior_layer_info[name] = LayerInfo(finished_coords=end_coords) |
247 | 243 | else: |
248 | 244 | final_str: str = ( |
249 | 245 | layer.text_template.replace("$data", data) if layer.text_template else data |
|
0 commit comments