A 2D stroke graphics library using the pen-and-path model.
Pen-Path provides primitives for creating stroke-based vector graphics, inspired by calligraphic and technical drawing traditions. A pen (circular, elliptical, or rectangular) traces along a path to produce filled outlines.
- Point: 2D coordinate in centipoints (7200 per inch)
- Path: Sequence of points connected by line, curve, or corner segments
- Pen: Shape that sweeps along a path
- Stroke: Filled envelope from sweeping a pen along a path
All coordinates use centipoints (Cp):
- 7200 centipoints = 1 inch
- 100 centipoints = 1 point (1/72 inch)
Integer coordinates avoid floating-point precision issues while providing sub-point accuracy.
| Symbol | Name | Description |
|---|---|---|
⏤ |
Line | Straight segment |
⌒ |
Curve | Smooth curve (Hobby's algorithm) |
∠ |
Corner | Sharp angle break |
↻ |
Cycle | Close path to start |
- Circular: Fixed-width strokes
- Elliptical: Calligraphic variation
- Rectangular: Technical/architectural lines
- RGB/RGBA: Screen display (0-255 per channel)
- CMYK: Print output (0-100% per channel)
- Grayscale: Single-channel with alpha
- HSL: Hue/Saturation/Lightness
- Spot: Named single-ink colors (Pantone-style) with tint
- Sepia: Warm monochrome for aged document aesthetics
use pen_path::{Point, Path, Pen, Color, Stroke, StrokeOptions};
use pen_path::render::SvgOps;
// Create a path (coordinates in centipoints)
let path = Path::builder()
.move_to(10000, 10000)
.line_to(50000, 10000)
.line_to(30000, 40000)
.close();
// Create a 10pt circular pen
let pen = Pen::circular(1000);
// Stroke and render
let stroke = Stroke::new(path, pen, Color::BLACK);
let envelope = stroke.to_envelope(&StrokeOptions::default());- PDF: Direct PDF path operators
- SVG: Standard SVG path data
Apache-2.0
Pen-Path is a component of the 「」 Lingenic Compose typesetting system.