diff --git a/Cargo.lock b/Cargo.lock index 72a6025..8a59816 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3,6 +3,7 @@ name = "loldog" version = "0.1.0" dependencies = [ "ansi_term 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rand 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -10,3 +11,16 @@ name = "ansi_term" version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "libc" +version = "0.2.15" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "rand" +version = "0.3.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "libc 0.2.15 (registry+https://github.com/rust-lang/crates.io-index)", +] + diff --git a/Cargo.toml b/Cargo.toml index c3eed22..bb4e187 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -4,4 +4,5 @@ version = "0.1.0" authors = ["logaritmisk "] [dependencies] +rand = "0.3" ansi_term = "0.9" diff --git a/src/main.rs b/src/main.rs index 51cd1a8..47a7719 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,19 +1,23 @@ +extern crate rand; extern crate ansi_term; use std::io; use std::io::prelude::*; use std::f32::consts::PI; +use rand::{thread_rng, Rng}; use ansi_term::Colour::RGB; fn main() { + let r = thread_rng().gen_range(0, 256); + let stdin = io::stdin(); for (n, line) in stdin.lock().lines().enumerate() { let line = line.unwrap(); for (o, c) in line.chars().enumerate() { - let (red, green, blue) = rainbow(0.1, n + o); + let (red, green, blue) = rainbow(0.1, r + n + o); print!("{}", RGB(red, green, blue).paint(c.to_string())); }