interactive!

This commit is contained in:
numzero 2026-10-08 21:38:09 +03:00
parent b37bd46a1f
commit 38f645218d

View File

@ -1,6 +1,7 @@
use std::{f32::consts::PI, time::Duration};
use flo_draw::{
DrawEvent, Key,
canvas::{Color::Rgba, GraphicsContext},
create_drawing_window_with_events, with_2d_graphics,
};
@ -93,16 +94,23 @@ fn main() {
let n_points_per_tooth = 100;
let n_points = n_points_per_tooth * n_teeth_sample;
let mut inv_shape = vec![r_pitch + ADDENDUM; n_points];
let mut bevel_shape = vec![r_pitch + ADDENDUM; n_points];
let show_crown_gear = false;
let show_crown_cutter = true;
let show_rack_gear = false;
let show_rack_cutter = true;
let mut bevel_shape = vec![r_pitch + 3.0 * ADDENDUM; n_points];
let mut show_crown_gear = false;
let mut show_crown_cutter = true;
let mut show_rack_gear = false;
let mut show_rack_cutter = true;
'main: loop {
while let Poll::Ready(event) =
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| {
gc.clear_canvas(Rgba(0.1, 0.1, 0.1, 1.0));
@ -228,7 +236,7 @@ fn main() {
if show_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();
}
if show_crown_gear {
@ -243,7 +251,7 @@ fn main() {
}
if show_rack_gear {
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();
}
});