Skip to content

Commit c036186

Browse files
committed
feat(meme): add meme anan
1 parent 969743b commit c036186

File tree

9 files changed

+86
-0
lines changed

9 files changed

+86
-0
lines changed

meme_generator_memes/src/memes.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ mod alike;
77
mod alipay;
88
mod always;
99
mod always_like;
10+
mod anan;
1011
mod anti_kidnap;
1112
mod anya_suki;
1213
mod applaud;
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
use skia_safe::{Color, FontStyle, IRect};
2+
3+
use meme_generator_core::error::Error;
4+
use meme_generator_utils::{
5+
builder::{InputImage, MemeOptions},
6+
canvas::CanvasExt,
7+
encoder::encode_png,
8+
image::ImageExt,
9+
text_params,
10+
tools::{load_image, local_date, new_paint},
11+
};
12+
13+
use crate::register_meme;
14+
15+
#[derive(MemeOptions)]
16+
struct Expression {
17+
/// 表情类型
18+
#[option(short, long, default="happy", choices=["angry", "black", "happy", "shy", "speechless"])]
19+
expression: Option<String>,
20+
}
21+
22+
fn anan(
23+
_: Vec<InputImage>,
24+
texts: Vec<String>,
25+
options: Expression,
26+
) -> Result<Vec<u8>, Error> {
27+
let text = &texts[0];
28+
let expression = options.expression.as_deref().unwrap_or("happy");
29+
30+
let base_image = load_image(&format!("anan/{}.png", expression))?;
31+
let mut surface = base_image.to_surface();
32+
let canvas = surface.canvas();
33+
34+
let text_rect = IRect::from_ltrb(105, 445, 412, 625);
35+
canvas.draw_text_area_auto_font_size(
36+
text_rect,
37+
text,
38+
20.0,
39+
60.0,
40+
text_params!(
41+
paint = new_paint(Color::BLACK),
42+
font_style = FontStyle::bold()
43+
),
44+
)?;
45+
46+
let hand_image = load_image("anan/hand.png")?;
47+
canvas.draw_image(&hand_image, (0, 0), None);
48+
49+
encode_png(surface.image_snapshot())
50+
}
51+
52+
register_meme!(
53+
"anan",
54+
anan,
55+
min_texts = 1,
56+
max_texts = 1,
57+
default_texts = &["吾辈很开心"],
58+
keywords = &["安安", "安安说"],
59+
date_created = local_date(2025, 11, 8),
60+
date_modified = local_date(2025, 11, 8),
61+
);

resources/images/anan/angry.png

254 KB
Loading

resources/images/anan/black.png

251 KB
Loading

resources/images/anan/hand.png

9.44 KB
Loading

resources/images/anan/happy.png

252 KB
Loading

resources/images/anan/shy.png

254 KB
Loading
254 KB
Loading

resources/resources.json

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,30 @@
110110
"file": "always_like/0.png",
111111
"hash": "303b6a4cd39c0e25c7f093902763c740eb3289e5335c5e39b13942f299fdf286"
112112
},
113+
{
114+
"file": "anan/angry.png",
115+
"hash": "d002863dd39d221010a32dbbcfad278a5876b087f40022054eb001c204c1075e"
116+
},
117+
{
118+
"file": "anan/black.png",
119+
"hash": "2ffee91f6dde8a22e07549d39cce1eb223622c82c22ff6783cbee779a03a5395"
120+
},
121+
{
122+
"file": "anan/hand.png",
123+
"hash": "de03cc289e6fb19ab392af8df2da883318cf421bb6e2777722f79d92e0b1dd02"
124+
},
125+
{
126+
"file": "anan/happy.png",
127+
"hash": "de97f0a8ddb73df18ecf8d33039c2e511f19efa31f6799a13b20237619c47ad9"
128+
},
129+
{
130+
"file": "anan/shy.png",
131+
"hash": "86668071d4bc1e7b00b43d3bf4af477845ac94a0bb48974280d1c65452f5762d"
132+
},
133+
{
134+
"file": "anan/speechless.png",
135+
"hash": "f3e1bf5b148bd16ebbfa98bfee22df07c39e7302ba832687c54843d05bf204fc"
136+
},
113137
{
114138
"file": "anti_kidnap/0.png",
115139
"hash": "5d82a378ed7b8103b80e12b30f3fb812afc17812eb5e8424f5a7d10d836191bb"

0 commit comments

Comments
 (0)