1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
//! # MunsellSpace 🎨
//!
//! High-precision **sRGB to Munsell color space conversion** with **99.98% reference accuracy**.
//!
//! This library provides the most accurate open-source implementation for converting RGB colors
//! to Munsell notation, validated against the complete 4,007-color reference dataset.
//!
//! ## Quick Start
//!
//! ```rust
//! use munsellspace::MunsellConverter;
//!
//! fn main() -> Result<(), Box<dyn std::error::Error>> {
//! let converter = MunsellConverter::new()?;
//!
//! // Convert RGB to Munsell
//! let munsell = converter.srgb_to_munsell([255, 0, 0])?;
//! println!("Pure red: {}", munsell); // Output: 7.9R 5.2/20.5
//!
//! Ok(())
//! }
//! ```
//!
//! ## Features
//!
//! - **99.98% Accuracy**: Validated against complete reference dataset (4,006/4,007 exact matches)
//! - **High Performance**: 4,000+ colors/second batch processing
//! - **Scientific Precision**: Reference data lookup with intelligent interpolation
//! - **Thread Safety**: Full support for concurrent usage with `Send + Sync` implementations
//! - **Semantic Color Names**: 30 color name overlays from Centore (2020) research
//! - **Comprehensive Testing**: Full test suite with accuracy validation
//!
//! ## About Munsell Color Space
//!
//! The Munsell color system describes colors using three perceptually uniform dimensions:
//!
//! - **Hue**: Color family (R, YR, Y, GY, G, BG, B, PB, P, RP)
//! - **Value**: Lightness from 0 (black) to 10 (white)
//! - **Chroma**: Saturation from 0 (neutral) to 15+ (vivid)
//!
//! Example: `5R 4.0/14.0` = medium red (5R) with medium lightness (4.0) and high saturation (14.0).
//!
//! ## Thread Safety
//!
//! All public types in MunsellSpace are thread-safe and implement `Send + Sync`. You can
//! safely share converters across multiple threads using `Arc<T>`:
//!
//! ```rust
//! use munsellspace::{MunsellConverter, IsccNbsClassifier};
//! use std::sync::Arc;
//! use std::thread;
//!
//! fn main() -> Result<(), Box<dyn std::error::Error>> {
//! // Create shared instances
//! let converter = Arc::new(MunsellConverter::new()?);
//! let classifier = Arc::new(IsccNbsClassifier::new()?);
//!
//! let mut handles = vec![];
//!
//! // Spawn multiple threads for concurrent processing
//! for thread_id in 0..4 {
//! let converter_clone = Arc::clone(&converter);
//! let classifier_clone = Arc::clone(&classifier);
//!
//! let handle = thread::spawn(move || {
//! // Each thread can safely use the converters concurrently
//! let munsell = converter_clone.srgb_to_munsell([255, 0, 0]).unwrap();
//!
//! if let (Some(hue), Some(chroma)) = (&munsell.hue, munsell.chroma) {
//! if let Ok(Some(iscc_color)) = classifier_clone.classify_munsell(hue, munsell.value, chroma) {
//! println!("Thread {}: {} -> {:?}", thread_id, munsell, iscc_color);
//! }
//! }
//! });
//!
//! handles.push(handle);
//! }
//!
//! // Wait for all threads to complete
//! for handle in handles {
//! handle.join().unwrap();
//! }
//!
//! Ok(())
//! }
//! ```
//!
//! Internal caches use `Arc<RwLock<T>>` for safe concurrent access, allowing multiple
//! readers or exclusive writers without data races.
//!
//! ## Semantic Color Names (v1.2.0+)
//!
//! MunsellSpace includes 30 semantic color name overlays derived from Paul Centore's
//! 2020 research paper "Beige, aqua, fuchsia, etc.: Definitions for some non-basic
//! surface colour names" (JAIC, 25, 24-54). These overlays define convex polyhedra
//! in Munsell space for each color name, allowing you to determine which color names
//! apply to any given Munsell color.
//!
//! ```rust
//! use munsellspace::{MunsellSpec, semantic_overlay, matching_overlays, get_registry};
//!
//! fn main() {
//! // Parse a Munsell color and find matching color names
//! let color = MunsellSpec::new(7.4, 6.2, 3.4); // Near aqua centroid
//!
//! // Get the best-matching color name
//! if let Some(name) = semantic_overlay(&color) {
//! println!("Best match: {}", name); // "aqua"
//! }
//!
//! // Get all matching color names (colors can match multiple names)
//! let matches = matching_overlays(&color);
//! println!("All matches: {:?}", matches);
//!
//! // Access the complete registry for advanced use
//! let registry = get_registry();
//! println!("Registry has {} overlays", registry.len()); // 30
//! }
//! ```
//!
//! **Available color names (30 total):**
//! - **Non-basic (20)**: aqua, beige, coral, fuchsia, gold, lavender, lilac, magenta,
//! mauve, navy, peach, rose, rust, sand, tan, taupe, teal, turquoise, violet, wine
//! - **Basic (10)**: blue, brown, gray, green, orange, pink, purple, red, white, yellow
//!
//! ## Unified Color Naming API (v1.2.0+)
//!
//! The [`ColorClassifier`] provides a unified interface for all color naming systems.
//! From any color input, get complete naming information with consistent modifiers
//! across ISCC-NBS standard, extended, and semantic names.
//!
//! ```rust
//! use munsellspace::{ColorClassifier, ColorModifier};
//!
//! fn main() -> Result<(), Box<dyn std::error::Error>> {
//! let classifier = ColorClassifier::new()?;
//!
//! // Classify any color format
//! let desc = classifier.classify_srgb([180, 80, 60])?;
//!
//! // Get descriptors from all naming systems
//! println!("Standard: {}", desc.standard_descriptor()); // "moderate reddish brown"
//! println!("Extended: {}", desc.extended_descriptor()); // "moderate rust"
//! if let Some(semantic) = desc.semantic_descriptor() {
//! println!("Semantic: {}", semantic); // "moderate rust"
//! }
//!
//! // The same modifier applies across all systems
//! println!("Modifier: {:?}", desc.modifier); // Moderate
//!
//! // Format any modifier + color combination
//! let formatted = ColorModifier::Vivid.format("coral");
//! println!("{}", formatted); // "vivid coral"
//!
//! Ok(())
//! }
//! ```
//!
//! ## Flexible Color Characterization (v1.2.1+)
//!
//! The new characterization API separates objective color facts from formatting preferences,
//! giving you complete control over how colors are described.
//!
//! ```rust
//! use munsellspace::{ColorClassifier, ColorCharacterization, FormatOptions, BaseColorSet, OverlayMode};
//!
//! fn main() -> Result<(), Box<dyn std::error::Error>> {
//! let classifier = ColorClassifier::new()?;
//!
//! // Get objective characterization
//! let char = classifier.characterize_srgb([0, 0, 128])?;
//!
//! // Access raw data
//! println!("ISCC-NBS #{}: {}", char.iscc_nbs_number, char.iscc_base_color);
//! println!("Semantic matches: {:?}", char.semantic_matches);
//!
//! // Format with different preferences
//! let standard = FormatOptions::new(BaseColorSet::Standard, OverlayMode::Ignore);
//! let with_overlay = FormatOptions::new(BaseColorSet::Extended, OverlayMode::Include);
//!
//! println!("Standard: {}", char.describe(&standard)); // "dark blue"
//! println!("With overlay: {}", char.describe(&with_overlay)); // "dark navy"
//!
//! // Preset options for common cases
//! println!("{}", char.describe(&FormatOptions::standard())); // "dark blue"
//! println!("{}", char.describe(&FormatOptions::extended())); // "dark blue"
//! println!("{}", char.describe(&FormatOptions::standard_with_overlays())); // "dark navy"
//! println!("{}", char.describe(&FormatOptions::extended_with_overlays())); // "dark navy"
//!
//! Ok(())
//! }
//! ```
//!
//! **`BaseColorSet`**: Controls which ISCC-NBS names to use
//! - `Standard`: 29 official ISCC-NBS base names ("vivid yellow green", "dark greenish blue")
//! - `Extended`: Uses lime/teal/turquoise for compound names ("vivid lime", "dark teal")
//!
//! **`OverlayMode`**: Controls semantic overlay behavior
//! - `Ignore`: Always use ISCC-NBS base colors
//! - `Include`: Use nearest semantic overlay when available
// Test modules were moved to their respective implementation files
// #[cfg(test)]
// mod comprehensive_unit_tests;
pub use MunsellConverter;
pub use ;
pub use ;
pub use ;
pub use ;
pub use MechanicalWedgeSystem;
pub use ;
pub use ;
pub use ;
pub use ;
// Deprecated semantic overlay functions (v1.2.0) - Use ColorClassifier instead
// These are re-exported for backward compatibility and will be removed in v2.0.0
pub use ;
pub use ;
// Unified color naming API (v1.2.0+)
pub use ;
// Note: General color conversions (RGB↔Hex↔Lab↔HSL↔HSV) are available via the palette crate
// We only expose Munsell-specific conversions to avoid duplication
/// Library version
pub const VERSION: &str = env!;