pub fn from_shorthand(shorthand: Vec<u32>) -> Sprite {
        let total: u32 = shorthand.iter().sum();
        if total != 100 {
            panic!("invalid sprite shorthand, must sum to 100");
        }

        let mut pixels = [false; 100];
        let (mut idx, mut value) = (0, false);
        for elem in shorthand.iter() {
            for _ in 0..*elem {
                pixels[idx] = value;
                idx += 1;
            }
            value = !value;
        }
        let mut s = Sprite {
            pixels,
            is_empty: true,
        };
        s.update_is_empty();
        s
    }
// shorthand is [number of false pixels, number of true pixels, number of false pixels...]
// until you've covered all 100 of the pixels
shorthand is [number of false pixels, number of true pixels, number of false pixels...]
until you've covered all 100 of the pixels
shorthand is [ number of false pixels number of true pixels number of false pixels ... ] until you ' ve covered all 100 of the pixels
pub fn from_shorthand(shorthand: Vec<u32>) -> Sprite {
        let total: u32 = shorthand.iter().sum();
        if total != 100 {
            panic!("invalid sprite shorthand, must sum to 100");
        }
        let mut pixels = [false; 100];
        let (mut idx, mut value) = (0, false);
        for elem in shorthand.iter() {
            for _ in 0..*elem {
                pixels[idx] = value;
                idx += 1;
            }
            value = !value;
        }
        let mut s = Sprite {
            pixels,
            is_empty: true,
        };
        s.update_is_empty();
        s
    }
pub fn from_shorthand ( shorthand : Vec < u32 > ) -> Sprite { let total : u32 = shorthand . iter ( ) . sum ( ) ; if total != 100 { panic ! ( " " ) ; } let mut pixels = [ false ; 100 ] ; let ( mut idx , mut value ) = ( 0 , false ) ; for elem in shorthand . iter ( ) { for _ in 0 .. * elem { pixels [ idx ] = value ; idx += 1 ; } value = ! value ; } let mut s = Sprite { pixels , is_empty : true , } ; s . update_is_empty ( ) ; s }
shorthand is [number of false pixels, number of true pixels, number of false pixels...]
until you've covered all 100 of the pixels
shorthand is [ number of false pixels number of true pixels number of false pixels ... ] until you ' ve covered all 100 of the pixels
shorthand
Vec<u32>
shorthand
Vec<u32>