docs.rs failed to build line_tools-0.2.0
Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.
Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.
📏 line_tools
High-performance line rendering for WebGL applications
A specialized library for rendering lines, curves, and vector graphics in WebGL. Optimized for real-time rendering with support for various line styles, anti-aliasing, and efficient batch processing. Perfect for data visualization, CAD applications, and interactive graphics.
✨ Features
📏 Line Rendering
- Anti-Aliased Lines - Smooth, high-quality line rendering
- Variable Width Lines - Support for dynamic line thickness
- Line Caps & Joins - Configurable line endings and connections
- Dash Patterns - Dashed and dotted line styles
✨ Visual Quality
- Multi-Sample Anti-Aliasing - Hardware-accelerated edge smoothing
- Smooth Curves - Bezier and spline curve rendering
- Color Gradients - Linear and radial gradient support
- Alpha Blending - Transparent and semi-transparent lines
⚡ Performance
- Batch Rendering - Efficient rendering of multiple lines
- WebGL Optimized - Direct GPU-accelerated rendering
- Memory Efficient - Minimal overhead for large datasets
- Real-Time Updates - Dynamic line modification support
🔧 Integration
- ndarray_cg Integration - Matrix transformation support
- minwebgl Compatibility - Seamless WebGL context integration
- Serialization Support - Save/load line data via serde
🚀 Installation
Add to your Cargo.toml:
= { = true }
💡 Quick Start
Basic Line Rendering
use *;
use minwebgl as gl;
use *;
Advanced Line Styling
use *;
📚 API Reference
Core Types
| Type | Description | Use Case |
|---|---|---|
LineRenderer |
Main rendering engine | All line drawing operations |
LineStyle |
Styling configuration | Colors, widths, patterns |
LineCap |
Line ending styles | Round, square, butt |
LineJoin |
Connection styles | Round, bevel, miter |
Rendering Methods
| Method | Purpose | Example |
|---|---|---|
draw_line() |
Render basic line | renderer.draw_line(&points) |
draw_curve() |
Render smooth curve | renderer.draw_curve(&control_points) |
draw_polyline() |
Connected line segments | renderer.draw_polyline(&vertices) |
draw_batch() |
Multiple lines efficiently | renderer.draw_batch(&line_data) |
Styling Options
renderer.draw_line
.width // Line thickness
.color // RGBA color
.dash_pattern // Dash pattern
.line_cap // Line endings
.line_join // Connections
.antialias // Smooth edges
.render?;
🎯 Use Cases
- Data Visualization - Charts, graphs, and plotting applications
- CAD Applications - Technical drawing and design tools
- Game Development - UI elements, debug visualization, effects
- Scientific Visualization - Mathematical plots and simulations
- Interactive Graphics - Drawing applications and creative tools
- Mapping Applications - Route visualization and geographic data
⚡ Performance Tips
Batch Rendering
// Efficient: batch multiple lines
let line1 = vec!;
let line2 = vec!;
let line3 = vec!;
let lines = vec!;
renderer.draw_batch.render?;
// Less efficient: individual calls
for line in lines
Memory Management
- Reuse
LineRendererinstances across frames - Use batch rendering for large datasets
- Pre-allocate vertex buffers for dynamic content
- Cache styled line configurations
🔬 Advanced Features
Matrix Transformations
Integration with ndarray_cg for complex transformations:
use *;
use PI;
let transform = scale * rot;
let points = vec!;
renderer.set_transform;
renderer.draw_line.render?;
Custom Shaders
Extend functionality with custom GLSL shaders:
let vertex_shader_source = "#version 300 es\n...";
let fragment_shader_source = "#version 300 es\n...";
let custom_shader = renderer.create_custom_shader?;
renderer.use_shader;
🛠️ Technical Details
WebGL Implementation
- Uses WebGL 2.0 features for optimal performance
- Implements proper depth testing and blending
- Supports instanced rendering for batch operations
- Utilizes vertex buffer objects (VBOs) for efficiency
Anti-Aliasing Techniques
- Multi-sample anti-aliasing (MSAA) support
- Screen-space anti-aliasing for thin lines
- Distance-based alpha blending for smooth edges
- Adaptive quality based on line width and zoom level
🚀 Getting Started
Add this to your Cargo.toml:
[]
= "0.1.0"
📖 Documentation
For detailed API documentation and examples, run:
🎮 Integration Examples
This crate works seamlessly with other cgtools modules:
- minwebgl: WebGL context management and shader utilities
- ndarray_cg: Mathematical transformations and matrix operations
- browser_tools: Logging and debugging in WebAssembly environments
Perfect for building comprehensive graphics applications with the cgtools ecosystem.