pride_overlay/lib.rs
1//! # Overview
2//!
3//! This crate provides functionality to overlay pride flags onto images.
4//! You can either [Overlay](effects::Overlay) a flag directly onto an image with adjustable opacity,
5//! or draw a [Ring](effects::Ring) around the image using the flag's colours,
6//! or create your own custom effects using the provided [Flag](flags::Flag) type and [Effect](effects::Effect) trait.
7//!
8//! | Input | Overlay | Ring |
9//! |:-----:|:-------:|:----:|
10//! |  |  |  |
11//!
12//! # High level API
13//! Load an image with the [`image`](https://docs.rs/image) crate, and [Overlay](effects::Overlay) the [Transgender](flags::PresetFlag::Transgender) flag with 40% opacity.
14//!
15//! ```rust
16//! use pride_overlay::prelude::*;
17//!
18//! let mut image = image::open("path/to/image.webp")?;
19//! let effect = Overlay::builder(PresetFlag::Transgender).opacity(Opacity::new(0.4)).build();
20//! effect.apply(&mut image);
21//! ```
22
23#[cfg(target_arch = "wasm32")]
24use wasm_bindgen::prelude::*;
25
26#[cfg(target_arch = "wasm32")]
27#[macro_use]
28extern crate serde;
29#[cfg(target_arch = "wasm32")]
30#[macro_use]
31extern crate tsify;
32
33mod colour;
34#[doc(inline)]
35pub use colour::Colour;
36
37/// Built-in image effects and related types.
38pub mod effects;
39
40/// Built-in pride flags and related types.
41pub mod flags;
42
43/// Commonly used types and traits.
44pub mod prelude {
45 pub use crate::{
46 Colour,
47 effects::{Effect, Overlay, Ring},
48 flags::{Flag, FlagData, PresetFlag, Svg, SvgData, SvgScaleMode},
49 };
50}
51
52#[cfg(target_arch = "wasm32")]
53#[wasm_bindgen(start)]
54#[doc(hidden)]
55pub fn init() {
56 // panic to the console
57 console_error_panic_hook::set_once();
58}