Initial commit.
This commit is contained in:
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
/target/
|
||||
12
Cargo.lock
generated
Normal file
12
Cargo.lock
generated
Normal file
@@ -0,0 +1,12 @@
|
||||
[root]
|
||||
name = "loldog"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"ansi_term 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ansi_term"
|
||||
version = "0.9.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
7
Cargo.toml
Normal file
7
Cargo.toml
Normal file
@@ -0,0 +1,7 @@
|
||||
[package]
|
||||
name = "loldog"
|
||||
version = "0.1.0"
|
||||
authors = ["logaritmisk <anders.e.olsson@gmail.com>"]
|
||||
|
||||
[dependencies]
|
||||
ansi_term = "0.9"
|
||||
18
src/main.rs
Normal file
18
src/main.rs
Normal file
@@ -0,0 +1,18 @@
|
||||
extern crate ansi_term;
|
||||
|
||||
use std::f32::consts::PI;
|
||||
use ansi_term::Colour::RGB;
|
||||
|
||||
fn main() {
|
||||
let (red, green, blue) = rainbow(0.1, 0);
|
||||
|
||||
println!("{}", RGB(red, green, blue).paint("Steel blue"));
|
||||
}
|
||||
|
||||
fn rainbow(frec: f32, i: usize) -> (u8, u8, u8) {
|
||||
let red = (f32::sin(frec * i as f32) * 127.0 + 128.0) as u8;
|
||||
let green = (f32::sin(frec * i as f32 + 2.0 * PI / 3.0) * 127.0 + 128.0) as u8;
|
||||
let blue = (f32::sin(frec * i as f32 + 4.0 * PI / 3.0) * 127.0 + 128.0) as u8;
|
||||
|
||||
(red, green, blue)
|
||||
}
|
||||
Reference in New Issue
Block a user