Skip to main content

trueno_viz/
lib.rs

1//! # Trueno-Viz
2//!
3//! SIMD/GPU/WASM-accelerated visualization library for data science and machine learning.
4//!
5//! Built on the [trueno](https://crates.io/crates/trueno) core library, trueno-viz provides
6//! hardware-accelerated rendering of statistical and scientific visualizations with zero
7//! JavaScript/HTML dependencies.
8//!
9//! ## Features
10//!
11//! - **Pure Rust**: No JavaScript, HTML, or browser dependencies
12//! - **Hardware Acceleration**: Automatic dispatch to SIMD (SSE2/AVX2/AVX512/NEON), GPU, or WASM
13//! - **Grammar of Graphics**: Declarative, composable visualization API
14//! - **Multiple Outputs**: PNG, SVG, and terminal (ASCII/Unicode) rendering
15//!
16//! ## Quick Start
17//!
18//! ```rust,ignore
19//! use trueno_viz::prelude::*;
20//!
21//! // Create a scatter plot
22//! let plot = ScatterPlot::new()
23//!     .x(&[1.0, 2.0, 3.0, 4.0, 5.0])
24//!     .y(&[2.0, 4.0, 1.0, 5.0, 3.0])
25//!     .color(Rgba::BLUE)
26//!     .build();
27//!
28//! // Render to PNG
29//! plot.render_to_file("scatter.png")?;
30//! ```
31//!
32//! ## Feature Flags
33//!
34//! - `gpu`: Enable GPU compute acceleration
35//! - `parallel`: Enable parallel processing with rayon
36//! - `ml`: Integration with aprender/entrenar ML libraries
37//! - `graph`: Integration with trueno-graph
38//! - `db`: Integration with trueno-db
39//! - `terminal`: Terminal output support
40//! - `svg`: SVG output support
41//! - `full`: All features enabled
42//!
43//! ## Academic References
44//!
45//! This library implements algorithms from peer-reviewed research:
46//!
47//! - Wilkinson, L. (2005). *The Grammar of Graphics*. Springer.
48//! - Wu, X. (1991). "An Efficient Antialiasing Technique." SIGGRAPH '91.
49//! - Douglas, D. H., & Peucker, T. K. (1973). Line simplification algorithm.
50//! - Fruchterman, T. M. J., & Reingold, E. M. (1991). Force-directed graph layout.
51
52#![cfg_attr(docsrs, feature(doc_cfg))]
53#![warn(missing_docs)]
54// Allow unwrap() in tests only - banned in production code (Cloudflare incident 2025-11-18)
55#![cfg_attr(test, allow(clippy::unwrap_used))]
56// Allow common patterns in graphics/visualization code
57#![allow(clippy::cast_possible_truncation)]
58#![allow(clippy::cast_sign_loss)]
59#![allow(clippy::cast_precision_loss)]
60#![allow(clippy::many_single_char_names)]
61#![allow(clippy::module_name_repetitions)]
62#![allow(clippy::similar_names)]
63#![allow(clippy::doc_markdown)]
64
65// ============================================================================
66// Core Modules
67// ============================================================================
68
69/// Color types and color space conversions.
70pub mod color;
71
72/// Core framebuffer for pixel rendering.
73pub mod framebuffer;
74
75/// Geometric primitives (points, lines, rectangles).
76pub mod geometry;
77
78/// Scale functions for data-to-visual mappings.
79pub mod scale;
80
81// ============================================================================
82// Visualization Modules
83// ============================================================================
84
85/// Grammar of Graphics implementation.
86pub mod grammar;
87
88/// High-level plot types (scatter, heatmap, histogram, etc.).
89pub mod plots;
90
91// ============================================================================
92// Rendering Modules
93// ============================================================================
94
95/// Rendering backends and rasterization.
96pub mod render;
97
98/// Output encoders (PNG, SVG, terminal).
99pub mod output;
100
101/// SIMD/GPU acceleration layer.
102pub mod accel;
103
104// ============================================================================
105// Optional Integration Modules
106// ============================================================================
107
108/// Text prompt interface for declarative visualization DSL.
109pub mod prompt;
110
111/// Ecosystem integrations (trueno-db, trueno-graph, aprender).
112pub mod interop;
113
114/// Dashboard widgets for experiment tracking and visualization.
115pub mod widgets;
116
117/// WebAssembly bindings for browser usage.
118#[cfg(feature = "wasm")]
119#[cfg_attr(docsrs, doc(cfg(feature = "wasm")))]
120pub mod wasm;
121
122/// TUI monitoring system (btop-like).
123#[cfg(feature = "monitor")]
124#[cfg_attr(docsrs, doc(cfg(feature = "monitor")))]
125pub mod monitor;
126
127// ============================================================================
128// Error Types
129// ============================================================================
130
131/// Error types for trueno-viz operations.
132pub mod error;
133
134pub use error::{Error, Result};
135
136// ============================================================================
137// Prelude
138// ============================================================================
139
140/// Commonly used types and traits for convenient imports.
141///
142/// ```rust,ignore
143/// use trueno_viz::prelude::*;
144/// ```
145pub mod prelude {
146    pub use crate::color::{Hsla, Rgba};
147    pub use crate::error::{Error, Result};
148    pub use crate::framebuffer::Framebuffer;
149    pub use crate::geometry::{Line, Point, Rect};
150    pub use crate::plots::{
151        ConfusionMatrix, Heatmap, HeatmapPalette, Histogram, LineChart, LineSeries, LossCurve,
152        PrCurve, RocCurve, ScatterPlot,
153    };
154    pub use crate::scale::{ColorScale, LinearScale, LogScale, Scale};
155    pub use crate::widgets::{ResourceBar, RunRow, RunStatus, RunTable, Sparkline, TrendDirection};
156}
157
158// ============================================================================
159// Re-exports
160// ============================================================================
161
162/// Re-export trueno for direct access to SIMD operations.
163pub use trueno;
164
165// ============================================================================
166// Tests
167// ============================================================================
168
169#[cfg(test)]
170mod tests {
171    #[test]
172    fn test_library_compiles() {
173        // Smoke test to ensure the library compiles
174        assert!(true);
175    }
176}