def load_actual(self, burn_waypoints_in=False):
# Clear old waypoints
for wp in self.edit_view.waypoints:
self.edit_view.remove_subview(wp)
self.edit_view.waypoints = []
# Load image
img_filename = self.filename
iv = ui.ImageView(frame=self.bg.bounds)
iv.image = ui.Image(img_filename)
self.edit_view.img = snapshot(iv)
self.multiplier = self.edit_view.img.size[1]/self.edit_view.height
# Load settings
json_filename = img_filename[:-3]+'json'
if os.path.exists(json_filename):
with open(json_filename) as fp:
settings = json.load(fp)
if isinstance(settings, dict):
locations = settings['waypoint_locations']
self.bg.image = ui.Image.named(settings['bg_filename'])
self.edit_view.bg_filename = settings['bg_filename']
else:
locations = settings
self.bg.image = ui.Image.named('backgrounds/caves.jpg')
self.edit_view.bg_filename = None
for loc in locations:
wp = self.edit_view.add_waypoint()
wp.center = loc
if burn_waypoints_in:
with ui.ImageContext(self.edit_view.width, self.edit_view.height) as ctx:
self.edit_view.img.draw()
ui.set_blend_mode(ui.BLEND_CLEAR)
ui.set_color('black')
for wp in self.edit_view.waypoints:
(x,y) = wp.center
path = ui.Path.oval(x-15, y-15, 30, 30)
path.fill()
self.edit_view.img = ctx.get_image()
评论列表
文章目录