Crystal Renderer¶
SVG and 3D Visualization - Renders crystal structures from CDL notation with export to multiple formats including SVG, STL, and glTF.
Interactive companion
See live examples in the Crystal Gallery, experiment with CDL notation in the CDL Playground, or take a practice quiz on related material.
Overview¶
Crystal Renderer provides comprehensive visualization capabilities:
- CDL Visualization: Generate SVG images from Crystal Description Language notation
- Multi-Format Export: SVG, PNG, JPG, STL, glTF
- Customizable Rendering: Face colors, axes, grid, labels
- Info Panels: FGA-style property panels on visualizations
- 3D Projection: Configurable elevation and azimuth angles
- Color Schemes: System-based and form-based coloring
Installation¶
For raster image export (PNG, JPG):
Requirements¶
- Python >= 3.10
- numpy >= 1.20.0
- matplotlib >= 3.5.0
- gemmology-cdl-parser >= 1.0.0
- gemmology-crystal-geometry >= 1.0.0
Optional Dependencies¶
cairosvg- SVG to raster conversionPillow- Image processingase- Atomic structure visualization
Quick Start¶
from crystal_renderer import generate_cdl_svg
# Generate SVG from CDL notation
generate_cdl_svg("cubic[m3m]:{111}@1.0 + {100}@1.3", "crystal.svg")
# Export to 3D formats
from crystal_geometry import create_octahedron
from crystal_renderer import export_stl, export_gltf
geom = create_octahedron()
export_stl(geom.vertices, geom.faces, "octahedron.stl")
export_gltf(geom.vertices, geom.faces, "octahedron.gltf")
Output Formats¶
| Format | Extension | Description |
|---|---|---|
| SVG | .svg |
Vector graphics, scalable |
| PNG | .png |
Raster with transparency |
| JPG | .jpg |
Compressed raster |
| STL | .stl |
3D printing format |
| glTF | .gltf |
Web/AR 3D format |
Related Packages¶
- cdl-parser - Crystal Description Language parser
- crystal-geometry - 3D geometry engine
- mineral-database - Mineral preset database
License¶
MIT License - see LICENSE for details.