maimai/
lib.rs

1//! [![Build Status](https://codeberg.org/d-k-bo/maimai/badges/workflows/rust.yml/badge.svg)](https://codeberg.org/d-k-bo/maimai/actions?workflow=rust.yml)
2//! [![crates.io](https://img.shields.io/crates/v/maimai)](https://lib.rs/crates/maimai)
3//! [![Documentation](https://img.shields.io/docsrs/maimai)](https://docs.rs/maimai)
4//! [![License](https://img.shields.io/crates/l/maimai)](https://codeberg.org/d-k-bo/maimai/src/branch/main/COPYING)
5//! [![Repository](https://img.shields.io/badge/Source%20Code-on%20Codeberg-blue?logo=Codeberg)](https://codeberg.org/d-k-bo/maimai/)
6//!
7//! *maimai* (\[\'maɪ̯maɪ̯\], Zangendeutsch for “meme”) provides a command-line
8//! application and a Rust library to generate [Memes] based on a declarative
9//! text format.
10//!
11//! This is intended to be an alternative to popular [WYSIWYG] meme editors,
12//! that don't give you much control and often have problems creating
13//! reproducable, high quality content.
14//!
15//! ![](https://codeberg.org/d-k-bo/maimai/media/branch/main/examples/creating-memes.webp)
16//!
17//! _**All image templates used in this project were hand-drawn by [Gee] for
18//! [Framamèmes] and published under the the terms of the [CC-0] License.**_
19//!
20//! # Usage
21//!
22//! In many cases, a meme is created from 3 “layers”:
23//!
24//! - the base image (often taken from a popular TV show or from stock images)
25//! - the text layout that defines, where text is placed on the base image and
26//!   how it is formatted
27//! - the text content
28//!
29//! The first two “layer” are usually shared between different memes and the
30//! text content is replaced for a different joke.
31//!
32//! A `maimai` meme definition is written as a [TOML] document that can extend
33//! other meme definions. This allows implementing the pattern described
34//! above.
35//!
36//! <table>
37//!     <tr>
38//!         <th>Source</th>
39//!         <th>Result</th>
40//!     </tr>
41//!     <tr>
42//! <td>
43//!
44//! ```toml
45//! # examples/templates/sophie-no-yes.toml
46//!
47#![doc = include_str!("../examples/templates/sophie-no-yes.toml")]
48//! ```
49//!
50//! </td>
51//! <td>
52//!
53//! <img src="https://codeberg.org/d-k-bo/maimai/media/branch/main/examples/templates/sophie-no-yes.webp" height="400" width="400"/>
54//!
55//! </td>
56//!     </tr>
57//!     <tr>
58//! <td>
59//!
60//! ```toml
61//! # examples/reuse.toml
62//!
63#![doc = include_str!("../examples/reuse.toml")]
64//! ```
65//!
66//! </td>
67//! <td>
68//!
69//! <img src="https://codeberg.org/d-k-bo/maimai/media/branch/main/examples/reuse.webp" height="400" width="400"/>
70//!
71//! </td>
72//!     </tr>
73//! </table>
74//!
75//!
76//! # License
77//!
78//! This project is licensed under the GNU Affero General Public License version 3 or (at your option) any later version (AGPL-3.0-or-later).
79//!
80//! [Memes]: https://en.wikipedia.org/wiki/Internet_meme
81//! [WYSIWYG]: https://en.wikipedia.org/wiki/WYSIWYG
82//! [Gee]: https://ptilouk.net/
83//! [Framamèmes]: https://framamemes.org/
84//! [CC-0]: https://creativecommons.org/publicdomain/zero/1.0/
85//! [TOML]: https://toml.io/
86
87#![cfg_attr(not(feature = "cli"), allow(dead_code))]
88#![cfg_attr(not(feature = "cli"), allow(unused_imports))]
89#![cfg_attr(docsrs, feature(doc_auto_cfg))]
90
91mod error;
92#[cfg(feature = "read")]
93mod files;
94mod meme;
95#[cfg(feature = "render")]
96mod render;
97#[cfg(feature = "render")]
98mod text;
99
100pub use self::{
101    error::{Error, ErrorKind, IncompleteMemeDefinition, Result},
102    meme::{Color, HAlign, Meme, MemeBase, PartialMeme, TextBox, TextOutline, VAlign, partial},
103};
104
105#[cfg(feature = "read")]
106pub use self::files::{FileProvider, FsFileProvider};