Skip to content

Commit

Permalink
feat: add meme genshin_eat (#120)
Browse files Browse the repository at this point in the history
* Create 0

* Add files via upload

* Add files via upload

* Delete meme_generator/memes/yae_eat directory

* Create 0

* Add files via upload

* Add files via upload

* Delete meme_generator/memes/genshin_eat/images/0

* Update __init__.py

* style: auto fix by pre-commit hooks

* adjust

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: meetwq <[email protected]>
  • Loading branch information
3 people committed Aug 6, 2024
1 parent d5f4f8e commit 40e5f07
Show file tree
Hide file tree
Showing 97 changed files with 55 additions and 0 deletions.
55 changes: 55 additions & 0 deletions meme_generator/memes/genshin_eat/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
from pathlib import Path

from pil_utils import BuildImage
from pydantic import Field

from meme_generator import MemeArgsModel, MemeArgsParser, MemeArgsType, add_meme
from meme_generator.utils import FrameAlignPolicy, Maker, make_gif_or_combined_gif

img_dir = Path(__file__).parent / "images"

help_text = "角色:1、八重神子,2、胡桃,3、妮露,4、可莉,5、刻晴,6、钟离"

parser = MemeArgsParser(prefix_chars="-/")
parser.add_argument("--character", "/角色", help=help_text, default=1)


class Model(MemeArgsModel):
character: int = Field(1, description=help_text)


def genshin_eat(images: list[BuildImage], texts, args: Model):
if args.character not in range(1, 7):
raise ValueError("角色参数错误,请选择1-6")
name = ["yae_miko", "hutao", "nilou", "klee", "keqing", "zhongli"][
args.character - 1
]

position_list = [(110, 249), (119, 228), (120, 209), (119, 202), (124, 221)]

def maker(i: int) -> Maker:
def make(img: BuildImage) -> BuildImage:
chara = BuildImage.open(img_dir / name / f"{i:02d}.png")
if i in range(4, 9):
food = img.convert("RGBA").circle().resize((36, 36), keep_ratio=True)
if i == 8:
food = food.resize((36, 27))
chara.paste(food, position_list[i - 4], alpha=True)
return chara

return make

return make_gif_or_combined_gif(
images[0], maker, 16, 0.08, FrameAlignPolicy.extend_loop
)


add_meme(
"genshin_eat",
genshin_eat,
min_images=1,
max_images=1,
args_type=MemeArgsType(parser, Model, [Model(character=i) for i in range(1, 7)]),
keywords=["原神吃"],
# TODO: patterns=
)
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 40e5f07

Please sign in to comment.