Crates.io | offroad |
lib.rs | offroad |
version | 0.1.2 |
created_at | 2025-07-28 14:41:34.800824+00 |
updated_at | 2025-09-25 00:31:20.547453+00 |
description | 2D offsetting for arc polylines/polygons. |
homepage | https://github.com/radevgit/offroad |
repository | https://github.com/radevgit/offroad |
max_upload_size | |
id | 1771220 |
size | 630,589 |
To use the Offroad library in your project, add the following to your Cargo.toml
:
[dependencies]
offroad = "0.1.2"
use togo::prelude::*;
use offroad::prelude::*;
fn main() {
// Configuration for offsetting
let mut cfg = OffsetCfg::default();
let mut svg = SVG::new(300.0, 300.0, Some("/tmp/arcline.svg"));
cfg.svg = Some(&mut svg);
// Show original arcline in SVG output
cfg.svg_orig = true;
// Show final offset arclines in SVG output
cfg.svg_final = true;
let arc0 = arc_circle_parametrization(point(40.0, 100.0), point(140.0, 200.0), 0.0);
let arc1 = arc_circle_parametrization(point(140.0, 200.0), point(240.0, 100.0), 0.5);
let arc2 = arc_circle_parametrization(point(240.0, 100.0), point(40.0, 100.0), 1.3);
let arcs_orig = vec![arc0, arc1, arc2];
// External offsetting
let offset_arclines = offset_arcline_to_arcline(&arcs_orig, 15.0, &mut cfg);
println!("Input arcline has {} vertices", arcs_orig.len());
println!("Output has {} arclines", offset_arclines.len());
for (i, arcline) in offset_arclines.iter().enumerate() {
println!("Arcline {}: {} vertices", i, arcline.len());
}
if let Some(svg) = cfg.svg.as_mut() {
// Write svg to file
svg.write_stroke_width(0.1);
}
}