araea-wordcloud
A high-performance word cloud visualization library implemented in pure Rust. Supports mask shapes, SVG/PNG dual output, custom fonts, and color schemes.
Features
- ⚡ Pure Rust Implementation - Efficient collision detection using bit operations
- 🖼️ Multiple Output Formats - Export as vector graphics (SVG) or bitmap (PNG)
- 🎭 Mask Support - Built-in shapes and custom image masks
- 🎨 Highly Customizable - Custom fonts, colors, rotation angles, and spacing
- 📦 Ready to Use - Built-in Chinese font support
Installation
[]
= "0.1"
Quick Start
use generate;
use fs;
Advanced Usage
use ;
let words = vec!;
let wordcloud = new
.size
.background
.color_scheme
.mask_preset
.font_size_range
.angles
.build?;
Examples
Simple Word Cloud

Chinese Dense Word Cloud

Run the examples:
cargo run --example simple- Basic usagecargo run --example mask_shape- Heart-shaped word cloudcargo run --example chinese_dense- High-density Chinese word cloudcargo run --example advanced- Custom colors and layout
Configuration Reference
Color Schemes
| Scheme | Style |
|---|---|
Ocean |
Ocean blue-green (default) |
Sunset |
Warm tones, red-orange-yellow |
Forest |
Forest green, natural style |
Berry |
Purple and bright orange |
Monochrome |
Black, white, and gray |
Rainbow |
Rainbow colors |
Preset Masks
| Shape | Description |
|---|---|
Circle |
Circle (default) |
Heart |
Heart shape |
Cloud |
Cloud shape |
Star |
Star shape |
Triangle |
Triangle |
Skull |
Skull shape |
Builder Options
| Method | Description | Default |
|---|---|---|
.size(w, h) |
Canvas dimensions | 800x600 |
.background(hex) |
Background color | #FFFFFF |
.colors(vec![...]) |
Custom color list | Ocean Scheme |
.font(bytes) |
Custom font file data | HarmonyOS Sans SC |
.mask(bytes) |
Custom mask image | None |
.padding(px) |
Word collision padding | 2 |
.word_spacing(px) |
Word spacing | 4.0 |
.seed(u64) |
Random seed (fixed layout) | Random |
Acknowledgments
Thanks to wordcloud.online for inspiration and reference. The word cloud rendering approach is inspired by this website, achieving efficient and visually appealing results.