Closed stevepentland closed 6 years ago
Sorry for the delay. I was down with the flu over the weekend and I've just now had the energy to get back to things.
Oh well glad to have you back and I hope you're feeling better! I saw that on Twitter so figured you still weren't feeling well.
Everything looks great! I deleted some extra blank lines and rebased from master.
Once the build is complete, I will merge this PR! :tada:
Thanks again for all of your excellent work! :smile:
Once color mixing lands, we'll be able to do cool things like create gradients!
Here's the source code for this:
//! This example shows how you can use color mixing and pen size to produce a smooth gradient
extern crate turtle;
use turtle::{Color, Turtle};
fn main() {
let mut turtle = Turtle::new();
turtle.drawing_mut().set_title("Gradients!");
turtle.set_pen_size(200.0);
turtle.pen_up();
turtle.backward(250.0);
turtle.pen_down();
turtle.wait_for_click();
let red: Color = "red".into();
let white: Color = "white".into();
for i in 0..100+1 {
turtle.set_pen_color(red.mix(white, i));
turtle.forward(5.0);
}
}
I'm going to add it to the repo as an example once this is merged. :smile:
Added tests for each, and private helper
to_hsl
to convert an RGB color into its component HSL values. Done in relation to #59I'm doing these in smaller batches in case anyone else wants to pick some up. Wouldn't want to have someone work on them and then get scooped.