本文整理汇总了Python中kivy.uix.image.Image.bg_rect方法的典型用法代码示例。如果您正苦于以下问题:Python Image.bg_rect方法的具体用法?Python Image.bg_rect怎么用?Python Image.bg_rect使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类kivy.uix.image.Image
的用法示例。
在下文中一共展示了Image.bg_rect方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __load_map_scene
# 需要导入模块: from kivy.uix.image import Image [as 别名]
# 或者: from kivy.uix.image.Image import bg_rect [as 别名]
def __load_map_scene(self, map_name):
scene_path = os.path.join('resources', 'maps', map_name, 'scene.json')
scene_dict = json.load(open(scene_path))
scene_width = 1080
scene_height = 800
layer_list = scene_dict['layers']
first_layer_dict = layer_list[0]
pivot_pos = (first_layer_dict['x'], first_layer_dict['y'])
for layer_dict in reversed(layer_list[1:]):
layer_pos = (layer_dict['x'] - pivot_pos[0], layer_dict['y'] - pivot_pos[1])
layer_size = (layer_dict['w'], layer_dict['h'])
layer_name = layer_dict['name']
layer_path = os.path.join('resources', 'maps', map_name, 'images', layer_name + '.png')
layer_color = [random(), random(), random(), 1]
layer_image = Image(source=layer_path, pos=layer_pos, size=layer_size, pos_hint={}, size_hint=(None, None), color=layer_color)
with layer_image.canvas.before:
layer_image.bg_rect = Line(rectangle=(layer_pos[0], layer_pos[1], layer_size[0], layer_size[1]))
self.add_widget(layer_image)
layer_label = Label(text="[color=000000]"+layer_name+"[/color]", pos=layer_pos, size=layer_size, pos_hint={}, size_hint=(None, None), markup=True)
self.add_widget(layer_label)
layer_label = Label(text="[color=000000]!!!![/color]", pos=(0, 0), pos_hint={}, size_hint=(None, None), markup=True)
self.add_widget(layer_label)