Function contour_tracing::bits_to_paths
source ·
[−]Expand description
A function that takes a 2D array of bits and an option as input and return a string of SVG Path commands as output.
Examples
use contour_tracing::bits_to_paths;
- A simple example with the closepaths option set to false:
let bits = vec![vec![ 0,1,1,1,0,0,1,1,1,1,1 ],
vec![ 1,0,0,0,1,0,1,0,0,0,1 ],
vec![ 1,0,0,0,1,0,1,0,1,0,1 ],
vec![ 1,0,0,0,1,0,1,0,0,0,1 ],
vec![ 0,1,1,1,0,0,1,1,1,1,1 ]];
println!("{}", bits_to_paths(bits, false));
- When the closepaths option is set to true, each path is closed with the SVG Path Z command:
println!("{}", bits_to_paths(bits, true));
- If you plan to reuse the array of bits after using this function, use the
to_vec()
method like this:
let bits = vec![vec![ 1,0,0 ],
vec![ 0,1,0 ],
vec![ 0,0,1 ]];
println!("{}", bits_to_paths(bits.to_vec(), true));
println!("{:?}", bits);