Skip to content

Commit d9ca586

Browse files
committed
add meme jiubingfufa and trolley
1 parent 1a24094 commit d9ca586

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

79 files changed

+145
-0
lines changed

meme_generator_memes/src/memes.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ mod interview;
107107
mod jerry_stare;
108108
mod jiji_king;
109109
mod jinhsi;
110+
mod jiubingfufa;
110111
mod jiujiu;
111112
mod jump;
112113
mod kaleidoscope;
@@ -240,6 +241,7 @@ mod together;
240241
mod tom_tease;
241242
mod tomb_yeah;
242243
mod trance;
244+
mod trolley;
243245
mod turn;
244246
mod twist;
245247
mod universal;
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
use skia_safe::{Color, IRect, Image};
2+
3+
use meme_generator_core::error::Error;
4+
use meme_generator_utils::{
5+
builder::InputImage,
6+
canvas::CanvasExt,
7+
encoder::{GifInfo, make_gif_or_combined_gif},
8+
image::ImageExt,
9+
text_params,
10+
tools::{load_image, local_date, new_paint, new_stroke_paint},
11+
};
12+
13+
use crate::{options::NoOptions, register_meme};
14+
15+
const DEFAULT_TEXT: &str = "此乃旧病复发也";
16+
17+
fn jiubingfufa(
18+
images: Vec<InputImage>,
19+
texts: Vec<String>,
20+
_: NoOptions,
21+
) -> Result<Vec<u8>, Error> {
22+
let text = if !texts.is_empty() {
23+
&texts[0]
24+
} else {
25+
DEFAULT_TEXT
26+
};
27+
28+
let func = |i: usize, images: Vec<Image>| {
29+
let frame = load_image(format!("jiubingfufa/{i:02}.jpg"))?;
30+
let mut surface = frame.to_surface();
31+
let canvas = surface.canvas();
32+
let img = images[0].circle().resize_exact((120, 120));
33+
canvas.draw_image(&img, (32, frame.height() - 162), None);
34+
if i > 9 {
35+
canvas.draw_text_area_auto_font_size(
36+
IRect::from_ltrb(0, 0, 290, 160),
37+
text,
38+
20.0,
39+
32.0,
40+
text_params!(
41+
paint = new_paint(Color::WHITE),
42+
stroke_paint = new_stroke_paint(Color::BLACK, 3.0),
43+
),
44+
)?;
45+
}
46+
Ok(surface.image_snapshot())
47+
};
48+
49+
make_gif_or_combined_gif(
50+
images,
51+
func,
52+
GifInfo {
53+
frame_num: 26,
54+
duration: 0.06,
55+
},
56+
None,
57+
)
58+
}
59+
60+
register_meme!(
61+
"jiubingfufa",
62+
jiubingfufa,
63+
min_images = 1,
64+
max_images = 1,
65+
max_texts = 1,
66+
min_texts = 0,
67+
keywords = &["旧病复发"],
68+
default_texts = &[DEFAULT_TEXT],
69+
date_created = local_date(2025, 4, 1),
70+
date_modified = local_date(2025, 4, 11),
71+
);
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
use skia_safe::Image;
2+
3+
use meme_generator_core::error::Error;
4+
use meme_generator_utils::{
5+
builder::InputImage,
6+
encoder::{GifInfo, make_gif_or_combined_gif},
7+
image::ImageExt,
8+
tools::{load_image, local_date},
9+
};
10+
11+
use crate::{options::NoOptions, register_meme};
12+
13+
fn trolley(images: Vec<InputImage>, _: Vec<String>, _: NoOptions) -> Result<Vec<u8>, Error> {
14+
let func = |i: usize, images: Vec<Image>| {
15+
let frame = load_image(format!("trolley/{i:02}.png"))?;
16+
let (w, h, x, y, angle) = if i < 25 {
17+
(65, 65, 21, 101, 0)
18+
} else if i < 28 {
19+
[
20+
(65, 65, 0, 101, 0),
21+
(65, 65, 0, 101, 0),
22+
(65, 65, -21, 101, 0),
23+
][i - 25]
24+
} else if (31..=43).contains(&i) {
25+
[
26+
(18, 18, 237, 25, 0),
27+
(18, 18, 215, 25, 0),
28+
(18, 18, 191, 25, 0),
29+
(18, 18, 169, 25, 0),
30+
(18, 18, 150, 25, 0),
31+
(18, 18, 129, 19, -20),
32+
(18, 18, 114, 16, -30),
33+
(18, 18, 92, 13, -40),
34+
(18, 18, 72, 9, -40),
35+
(18, 18, 51, 6, -80),
36+
(18, 18, 27, 7, -90),
37+
(18, 18, 1, 8, -90),
38+
(18, 18, -15, 8, -90),
39+
][i - 31]
40+
} else {
41+
return Ok(frame);
42+
};
43+
let mut surface = frame.to_surface();
44+
let canvas = surface.canvas();
45+
let img = images[0]
46+
.circle()
47+
.resize_exact((w, h))
48+
.rotate_crop(angle as f32);
49+
canvas.draw_image(&img, (x, y), None);
50+
Ok(surface.image_snapshot())
51+
};
52+
53+
make_gif_or_combined_gif(
54+
images,
55+
func,
56+
GifInfo {
57+
frame_num: 50,
58+
duration: 0.05,
59+
},
60+
None,
61+
)
62+
}
63+
64+
register_meme!(
65+
"trolley",
66+
trolley,
67+
min_images = 1,
68+
max_images = 1,
69+
keywords = &["推车"],
70+
date_created = local_date(2025, 4, 12),
71+
date_modified = local_date(2025, 4, 12),
72+
);
53.5 KB
52.4 KB
50.8 KB
50.8 KB
50.7 KB
50.7 KB
50.7 KB

0 commit comments

Comments
 (0)