def get_whip_frames(avatar: Image.Image) -> List[Image.Image]: """Get frames for the whip""" frames = [] width, height = 250, 150 deformation = (0, 0, 0, 0, 0, 0, 0, 0, 2, 3, 5, 9, 6, 4, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0) translation = (0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 2, 3, 3, 3, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0) avatar = image_utils.round_image(avatar.resize((100, 100))) for i in range(26): img = "%02d" % (i + 1) frame = Image.new("RGBA", (width, height), (54, 57, 63, 1)) whip_frame = Image.open(f"data/meme/whip/{img}.png").resize( (150, 150)) frame_avatar = avatar.resize((100 - deformation[i], 100)) frame.paste(frame_avatar, (135 + deformation[i] + translation[i], 25), frame_avatar) frame.paste(whip_frame, (0, 0), whip_frame) frames.append(frame) return frames
def add_border(image: Image.Image, border: int, animal: bool) -> Image.Image: """Add border to created image. image: The avatar. border: width of the border. animal: whether the avatar is an animal or not. """ image_size = 160 frame_color = (22, 229, 0, 1) if animal else (221, 56, 31, 1) frame = Image.new("RGBA", (image_size + border * 2, image_size + border * 2), frame_color) frame = image_utils.round_image(frame) avatar = image_utils.round_image(image.resize( (image_size, image_size))) frame.paste(avatar, (border, border), avatar) return frame
def get_pet_frames(avatar: Image.Image) -> List[Image.Image]: """Get frames for the pet""" frames = [] width, height = 148, 148 vertical_offset = (0, 0, 0, 0, 1, 2, 3, 4, 5, 4, 3, 2, 2, 1, 0) frame_avatar = image_utils.round_image(avatar.resize((100, 100))) for i in range(14): img = "%02d" % (i + 1) frame = Image.new("RGBA", (width, height), (54, 57, 63, 1)) hand = Image.open(f"data/meme/pet/{img}.png") frame.paste(frame_avatar, (35, 25 + vertical_offset[i]), frame_avatar) frame.paste(hand, (10, 5), hand) frames.append(frame) return frames
def get_bonk_frames(avatar: Image.Image) -> List[Image.Image]: """Get frames for the bonk""" frames = [] width, height = 200, 170 deformation = (0, 0, 0, 5, 10, 20, 15, 5) avatar = image_utils.round_image(avatar.resize((100, 100))) for i in range(8): img = "%02d" % (i + 1) frame = Image.new("RGBA", (width, height), (54, 57, 63, 1)) bat = Image.open(f"data/meme/bonk/{img}.png") frame_avatar = avatar.resize((100, 100 - deformation[i])) frame.paste(frame_avatar, (80, 60 + deformation[i]), frame_avatar) frame.paste(bat, (10, 5), bat) frames.append(frame) return frames
def get_spank_frames(avatar: Image.Image) -> List[Image.Image]: """Get frames for the spank""" frames = [] width, height = 200, 120 deformation = (4, 2, 1, 0, 0, 0, 0, 3) avatar = image_utils.round_image(avatar.resize((100, 100))) for i in range(8): img = "%02d" % (i + 1) frame = Image.new("RGBA", (width, height), (54, 57, 63, 1)) spoon = Image.open(f"data/meme/spank/{img}.png").resize((100, 100)) frame_avatar = avatar.resize( (100 + 2 * deformation[i], 100 + 2 * deformation[i])) frame.paste(spoon, (10, 15), spoon) frame.paste(frame_avatar, (80 - deformation[i], 10 - deformation[i]), frame_avatar) frames.append(frame) return frames
def get_hyperpet_frames(avatar: Image.Image) -> List[Image.Image]: """Get frames for the hyperpet""" frames = [] width, height = 148, 148 vertical_offset = (0, 1, 2, 3, 1, 0) avatar = image_utils.round_image(avatar.resize((100, 100))) avatar_pixels = np.array(avatar) git_hash = int(utils.git_get_hash(), 16) for i in range(6): deform_hue = git_hash % 100**(i + 1) // 100**i / 100 frame_avatar = Image.fromarray( image_utils.shift_hue(avatar_pixels, deform_hue)) img = "%02d" % (i + 1) frame = Image.new("RGBA", (width, height), (54, 57, 63, 1)) hand = Image.open(f"data/meme/hyperpet/{img}.png") frame.paste(frame_avatar, (35, 25 + vertical_offset[i]), frame_avatar) frame.paste(hand, (10, 5), hand) frames.append(frame) return frames