@@ -39,22 +39,22 @@ def __init__(
39
39
self .__auto_write = auto_write
40
40
self .__contents = []
41
41
self .__max_size = max_size
42
- self .scale = scale
42
+ self .__scale = scale
43
43
"""
44
44
.. attribute:: scale
45
45
46
46
Scales each pixel within the Group in both directions. For example, when scale=2 each pixel
47
47
will be represented by 2x2 pixels.
48
48
49
49
"""
50
- self .x = x
50
+ self .__x = x
51
51
"""
52
52
.. attribute:: x
53
53
54
54
X position of the Group in the parent.
55
55
56
56
"""
57
- self .y = y
57
+ self .__y = y
58
58
"""
59
59
.. attribute:: y
60
60
@@ -63,6 +63,36 @@ def __init__(
63
63
self .__parent = None
64
64
self .__hidden = False
65
65
66
+ @property
67
+ def x (self ):
68
+ return self .__x
69
+
70
+ @x .setter
71
+ def x (self , val ):
72
+ if self .__x != val :
73
+ self .__x = val
74
+ self .__elem_changed ()
75
+
76
+ @property
77
+ def y (self ):
78
+ return self .__y
79
+
80
+ @y .setter
81
+ def y (self , val ):
82
+ if self .__y != val :
83
+ self .__y = val
84
+ self .__elem_changed ()
85
+
86
+ @property
87
+ def scale (self ):
88
+ return self .__scale
89
+
90
+ @scale .setter
91
+ def scale (self , val ):
92
+ if self .__scale != val :
93
+ self .__scale = val
94
+ self .__elem_changed ()
95
+
66
96
@property
67
97
def hidden (self ):
68
98
"""
@@ -255,23 +285,24 @@ def __draw(self, img=None, x=0, y=0, scale=None, show=True):
255
285
# 1 unit (1 unit * scale = scale)
256
286
y -= scale
257
287
258
- # Group is positioned against anchored_position (default (0,0) ),
288
+ # Group is positioned against anchored_position (already incorporated into self.x and self.y ),
259
289
# which is positioned against anchor_point
260
290
261
291
x += self ._anchor_point [0 ]
262
292
y += self ._anchor_point [1 ]
263
- if self ._boundingbox is not None and self .anchored_position is not None :
264
- x += self .anchored_position [0 ]
265
- y += self .anchored_position [1 ]
266
293
except AttributeError :
267
294
pass
268
295
269
296
for elem in self .__contents :
270
297
if not elem .hidden :
271
298
if isinstance (elem , Group ):
272
- img = elem ._Group__draw (img = img , x = x , y = y , scale = scale , show = False ,)
299
+ img = elem ._Group__draw (
300
+ img = img , x = x + self .x , y = y + self .y , scale = scale , show = False ,
301
+ )
273
302
else :
274
- img = elem ._TileGrid__draw (img = img , x = x , y = y , scale = scale )
303
+ img = elem ._TileGrid__draw (
304
+ img = img , x = x + self .x , y = y + self .y , scale = scale
305
+ )
275
306
276
307
# show should only be true to the highest parent group
277
308
if show :
0 commit comments