Now with random seed.

This commit is contained in:
2016-09-01 08:40:46 +02:00
parent c548dfcf92
commit ff78008e2c
3 changed files with 20 additions and 1 deletions

14
Cargo.lock generated
View File

@@ -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)",
]

View File

@@ -4,4 +4,5 @@ version = "0.1.0"
authors = ["logaritmisk <anders.e.olsson@gmail.com>"]
[dependencies]
rand = "0.3"
ansi_term = "0.9"

View File

@@ -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()));
}