def draw_frames_merged(self, color_table): # generate all frames, them merge them on one big texture # player-specific colors will be in color blue, but with an alpha of 254 player_id = 1 max_width = 0 max_height = 0 slp_pngs = [] for frame in self.frames: png = PNG(player_id, color_table, frame.get_picture_data()) png.create() if png.width > max_width: max_width = png.width if png.height > max_height: max_height = png.height slp_pngs.append((png, frame.info.size, frame.info.hotspot)) # now we collected all sprites and can start merging them to one # big texture atlas. atlas, atlas_meta, (width, height) = merge_frames(slp_pngs, max_width, max_height) meta_out = generate_meta_text(atlas_meta) return atlas, (width, height), meta_out
def draw_alpha_frames_merged(self): for idx, bmode in enumerate(self.blending_modes): max_w = 0 max_h = 0 blendomatic_frames = [] for tile in bmode["alphamasks"]: frame = PNG(0, None, tile["data"]) tw = tile["width"] th = tile["height"] frame.create(tw, th, True) if tw > max_w: max_w = tw if th > max_h: max_h = th blendomatic_frames.append((frame, None, (0, 0))) atlas, atlas_meta, (width, height) = merge_frames(blendomatic_frames, max_w, max_h) meta_out = generate_meta_text(atlas_meta) yield idx, atlas, (width, height), meta_out
def draw_frames(self, color_table): # player-specific colors will be in color blue, but with an alpha of 254 player_id = 1 for idx, frame in enumerate(self.frames): png = PNG(player_id, color_table, frame.get_picture_data()) png.create() # this sprite png only contains one texture, therefore x and y are 0 drawn_meta = { "tx": 0, "ty": 0, "tw": frame.info.size[0], "th": frame.info.size[1], "hx": frame.info.hotspot[0], "hy": frame.info.hotspot[1], } meta_out = generate_meta_text([drawn_meta]) yield png, meta_out