interactive!
This commit is contained in:
parent
b37bd46a1f
commit
38f645218d
24
src/main.rs
24
src/main.rs
|
|
@ -1,6 +1,7 @@
|
||||||
use std::{f32::consts::PI, time::Duration};
|
use std::{f32::consts::PI, time::Duration};
|
||||||
|
|
||||||
use flo_draw::{
|
use flo_draw::{
|
||||||
|
DrawEvent, Key,
|
||||||
canvas::{Color::Rgba, GraphicsContext},
|
canvas::{Color::Rgba, GraphicsContext},
|
||||||
create_drawing_window_with_events, with_2d_graphics,
|
create_drawing_window_with_events, with_2d_graphics,
|
||||||
};
|
};
|
||||||
|
|
@ -93,16 +94,23 @@ fn main() {
|
||||||
let n_points_per_tooth = 100;
|
let n_points_per_tooth = 100;
|
||||||
let n_points = n_points_per_tooth * n_teeth_sample;
|
let n_points = n_points_per_tooth * n_teeth_sample;
|
||||||
let mut inv_shape = vec![r_pitch + ADDENDUM; n_points];
|
let mut inv_shape = vec![r_pitch + ADDENDUM; n_points];
|
||||||
let mut bevel_shape = vec![r_pitch + ADDENDUM; n_points];
|
let mut bevel_shape = vec![r_pitch + 3.0 * ADDENDUM; n_points];
|
||||||
let show_crown_gear = false;
|
let mut show_crown_gear = false;
|
||||||
let show_crown_cutter = true;
|
let mut show_crown_cutter = true;
|
||||||
let show_rack_gear = false;
|
let mut show_rack_gear = false;
|
||||||
let show_rack_cutter = true;
|
let mut show_rack_cutter = true;
|
||||||
'main: loop {
|
'main: loop {
|
||||||
while let Poll::Ready(event) =
|
while let Poll::Ready(event) =
|
||||||
events.poll_next_unpin(&mut Context::from_waker(Waker::noop()))
|
events.poll_next_unpin(&mut Context::from_waker(Waker::noop()))
|
||||||
{
|
{
|
||||||
let Some(_event) = event else { break 'main };
|
let Some(event) = event else { break 'main };
|
||||||
|
match event {
|
||||||
|
DrawEvent::KeyDown(_, Some(Key::KeyTab)) => {
|
||||||
|
(show_crown_gear, show_crown_cutter) = (show_crown_cutter, show_crown_gear);
|
||||||
|
(show_rack_gear, show_rack_cutter) = (show_rack_cutter, show_rack_gear);
|
||||||
|
}
|
||||||
|
_ => {}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
canvas.draw(|gc| {
|
canvas.draw(|gc| {
|
||||||
gc.clear_canvas(Rgba(0.1, 0.1, 0.1, 1.0));
|
gc.clear_canvas(Rgba(0.1, 0.1, 0.1, 1.0));
|
||||||
|
|
@ -228,7 +236,7 @@ fn main() {
|
||||||
|
|
||||||
if show_crown_cutter {
|
if show_crown_cutter {
|
||||||
line(gc, crown_cutter);
|
line(gc, crown_cutter);
|
||||||
gc.stroke_color(Rgba(1.0, 1.0, 0.1, 0.4));
|
gc.stroke_color(Rgba(1.0, 0.8, 0.1, 0.4));
|
||||||
gc.stroke();
|
gc.stroke();
|
||||||
}
|
}
|
||||||
if show_crown_gear {
|
if show_crown_gear {
|
||||||
|
|
@ -243,7 +251,7 @@ fn main() {
|
||||||
}
|
}
|
||||||
if show_rack_gear {
|
if show_rack_gear {
|
||||||
line(gc, pts_rack);
|
line(gc, pts_rack);
|
||||||
gc.stroke_color(Rgba(0.1, 1.0, 0.1, 0.4));
|
gc.stroke_color(Rgba(0.8, 1.0, 0.1, 0.4));
|
||||||
gc.stroke();
|
gc.stroke();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user