Skip to main content

deq_shapes/
lib.rs

1//! `deq-shapes`: traditional Kurdish tattoo (deq) motifs as parametric shapes.
2//!
3//! A port of the TypeScript reference renderer: SVG and PDF output match it byte for byte
4//! (ADR 0008, ADR 0011).
5
6// The renderer mirrors the TypeScript reference: exact float comparisons follow its `===`
7// semantics, and short maths names (x, y, c, s) follow the formulas.
8#![allow(
9    clippy::float_cmp,
10    clippy::many_single_char_names,
11    clippy::format_push_string,
12    clippy::format_collect
13)]
14
15pub mod color;
16mod data;
17pub mod drawing;
18pub mod error;
19pub mod expand;
20pub mod export;
21pub mod flag;
22pub mod format;
23pub mod generate;
24pub mod geometry;
25mod json;
26pub mod leet;
27pub mod options;
28mod pattern;
29pub mod pdf;
30pub mod random;
31pub mod raster;
32pub mod registry;
33pub mod scene;
34pub mod svg;
35mod trig;
36pub mod validate;
37
38pub use error::{DeqError, ErrorCode, Result};
39pub use flag::render_flag;
40pub use generate::{PatternResult, pattern};
41pub use leet::{DecodedLeet, LeetResult, Script, decode_leet, detect_script, leet, leet_table};
42pub use random::Random;
43pub use registry::{get_shape, has_shape, list_categories, list_shapes};
44pub use scene::{Cell, Scene, scene_svg};
45pub use svg::{compose, render};
46
47/// The crate name as published on crates.io.
48pub const CRATE_NAME: &str = env!("CARGO_PKG_NAME");
49
50/// The crate version (shared, unified Deq version).
51pub const VERSION: &str = env!("CARGO_PKG_VERSION");
52
53#[cfg(test)]
54mod tests {
55    use super::*;
56
57    #[test]
58    fn crate_name_matches() {
59        assert_eq!(CRATE_NAME, "deq-shapes");
60    }
61
62    #[test]
63    fn version_is_semver() {
64        let digits = |p: &str| !p.is_empty() && p.chars().all(|c| c.is_ascii_digit());
65        let (core, pre) = VERSION.split_once('-').unwrap_or((VERSION, ""));
66        let parts: Vec<&str> = core.split('.').collect();
67        assert_eq!(parts.len(), 3);
68        assert!(parts.iter().all(|p| digits(p)));
69        if !pre.is_empty() {
70            let (tag, n) = pre.split_once('.').unwrap_or((pre, ""));
71            assert!(["alpha", "beta", "rc"].contains(&tag), "pre-release {pre}");
72            assert!(digits(n), "pre-release {pre}");
73        }
74    }
75}