paperdoll/
lib.rs

1//! 2D pixel-based stationary paper doll model.
2//!
3//! - It's 2D.
4//! - It's pixel-based. Vector images and basic shapes are not supported in the current version.
5//! - It's stationary. Animations and transformations are not supported in the current version.
6//!
7//! Latest version: 1.
8//!
9//! ## Design
10//!
11//! The model consists of three parts: **doll**, **slot**, and **fragment**.
12//!
13//! ### Doll
14//!
15//! Dolls are the fundamental parts of your model. Normally, they represent faces, bodies, or any other assembled objects in your projects. A doll contains multiple slots.
16//!
17//! ### Slot
18//!
19//! Slots are where your paper doll can have alternative styles. For example, in a doll that represents a human's face, they could be eyes, mouth, nose, and so on.
20//!
21//! A slot can be placed in different positions inside the doll (eg. slot of eyes). Not all slots need to have images to be shown, they can be empty. For instance, an empty 'hair' slot means that the person is bald.
22//!
23//! Each slot has several alternative images to display. they're called '**candidates**'. And those candidates are all defined as fragments.
24//!
25//! ### Fragment
26//!
27//! Fragments are image assets that you can put into a slot as candidates. In `paperdoll`, all fragments are raster images. One fragment can be used in multiple slots.
28//!
29//! There are two ways slots and their fragment candidates are connected.
30//!
31//! - **Constrainted**. The fragment acts like the background of the slot. It will fill the whole space of the slot and resizes if needed.
32//!
33//! - **Non-constrainted**. Slots and fragments are connected like mortises and tenons. There is an anchor point inside a slot. When a fragment is placed into a slot, the pivot point of that fragment will be placed in the same position as the anchor point. The fragment remains its original size and resizing will never happen.
34//!
35//! ![core-concept](https://raw.githubusercontent.com/fralonra/paperdoll/master/doc/paperdoll-concept.png)
36//!
37//! ### Examples
38//!
39//! See [`PaperdollFactory`].
40
41mod builder;
42mod common;
43mod doll;
44mod factory;
45mod fragment;
46mod id_factory;
47mod image;
48mod manifest;
49mod meta;
50mod paperdoll;
51mod render_material;
52mod slot;
53
54pub use crate::paperdoll::Paperdoll;
55pub use builder::PaperdollBuilder;
56pub use common::Point;
57pub use doll::Doll;
58pub use factory::PaperdollFactory;
59pub use fragment::Fragment;
60pub use image::{ColorType, ImageData};
61pub use manifest::Manifest;
62pub use meta::Meta;
63pub use render_material::{RenderMaterial, RenderPiece};
64pub use slot::Slot;
65
66/// The latest version of paperdoll.
67pub const VERSION: u32 = 1;