[][src]Function contour_tracing::bits_to_paths

pub fn bits_to_paths(bits: Vec<Vec<i8>>, closepaths: bool) -> String

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

extern crate contour_tracing;
use contour_tracing::bits_to_paths;
  • A simple example with the closepaths option set to false:
let bits = vec![vec![ 0,0,0,0,0,0,0,0,0,0,0,0,0 ],
                vec![ 0,0,1,1,1,0,0,1,1,1,1,1,0 ],
                vec![ 0,1,0,0,0,1,0,1,0,0,0,1,0 ],
                vec![ 0,1,0,0,0,1,0,1,0,1,0,1,0 ],
                vec![ 0,1,0,0,0,1,0,1,0,0,0,1,0 ],
                vec![ 0,0,1,1,1,0,0,1,1,1,1,1,0 ],
                vec![ 0,0,0,0,0,0,0,0,0,0,0,0,0 ]];

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);