pub fn draw_canvas(dims: &[String]) -> Option<String> {
    // declare variables for storing canvas and dimensions
    let mut xydims: Vec<u32> = Vec::new();
    let mut canvas = String::new();
    
    // get dimensions for canvas
    if dims.len() != 0 {
        for line in get_dims(&dims).unwrap().lines() {
            xydims.push(line.parse().unwrap());
        }
        // build base canvas
        for _x in 0..xydims[0] {  // build rows
            let mut curr_str = "".to_string();
            for _y in 0..xydims[1] {  // build columns
                curr_str = curr_str + ".";
            }
            writeln!(&mut canvas, "{}", curr_str).unwrap();
        }
    }
    Some(canvas)
}
/// Draw base canvas from tvg file input.
/// Canvas size input from the first line of the tvg file.
/// This line contains the canvas dimensions: 
/// rows columns
///
/// # Examples:
///
/// ```
/// # use asciilines::*;
/// assert_eq!(Some(".....\n.....\n.....\n".to_string()), draw_canvas(&[String::from("3 5")]));
/// ```
/// ```
/// # use asciilines::*;
/// assert_eq!(Some("".to_string()), draw_canvas(&[String::from("0 0")]));
/// ```
Draw base canvas from tvg file input.
Canvas size input from the first line of the tvg file.
This line contains the canvas dimensions:
rows columns
Draw base canvas from tvg file input . Canvas size input from the first line of the tvg file . This line contains the canvas dimensions : rows columns
pub fn draw_canvas(dims: &[String]) -> Option<String> {
    // declare variables for storing canvas and dimensions
    let mut xydims: Vec<u32> = Vec::new();
    let mut canvas = String::new();
    // get dimensions for canvas
    if dims.len() != 0 {
        for line in get_dims(&dims).unwrap().lines() {
            xydims.push(line.parse().unwrap());
        }
        // build base canvas
        for _x in 0..xydims[0] {  // build rows
            let mut curr_str = "".to_string();
            for _y in 0..xydims[1] {  // build columns
                curr_str = curr_str + ".";
            }
            writeln!(&mut canvas, "{}", curr_str).unwrap();
        }
    }
    Some(canvas)
}
pub fn draw_canvas ( dims : & [ String ] ) -> Option < String > { // declare variables for storing canvas and dimensions let mut xydims : Vec < u32 > = Vec :: new ( ) ; let mut canvas = String :: new ( ) ; // get dimensions for canvas if dims . len ( ) != 0 { for line in get_dims ( & dims ) . unwrap ( ) . lines ( ) { xydims . push ( line . parse ( ) . unwrap ( ) ) ; } // build base canvas for _x in 0 .. xydims [ 0 ] { // build rows let mut curr_str = " " . to_string ( ) ; for _y in 0 .. xydims [ 1 ] { // build columns curr_str = curr_str + " " ; } writeln ! ( mut canvas " " curr_str ) . unwrap ( ) ; } } Some ( canvas ) }
Draw base canvas from tvg file input.
Draw base canvas from tvg file input .
dims
&[String]
dims
&[String]
examples:
None
use asciilines::*;
None
use asciilines::*;
None