improve speed to have one single point of truth.
This commit is contained in:
@@ -13,20 +13,23 @@ async fn main() {
|
||||
plan.set_color(RED);
|
||||
plan.set_pen_width(0.5);
|
||||
plan.left(90.0);
|
||||
plan.set_speed(999);
|
||||
plan.circle_left(100.0, 540.0, 72); // partial circle to the left
|
||||
|
||||
plan.forward(150.0);
|
||||
|
||||
plan.set_speed(100);
|
||||
plan.set_color(BLUE);
|
||||
plan.circle_right(50.0, 270.0, 72); // partial circle to the right
|
||||
|
||||
// Set animation speed
|
||||
plan.set_speed(20);
|
||||
plan.forward(150.0);
|
||||
|
||||
plan.set_speed(700);
|
||||
plan.set_color(GREEN);
|
||||
plan.circle_left(50.0, 180.0, 36); // Half circle to the left
|
||||
|
||||
// Create turtle app with animation (speed = 100 pixels/sec)
|
||||
let mut app = TurtleApp::new().with_commands(plan.build(), 100.0);
|
||||
let mut app = TurtleApp::new().with_commands(plan.build());
|
||||
|
||||
// Main loop
|
||||
loop {
|
||||
|
||||
@@ -8,14 +8,15 @@ async fn main() {
|
||||
// Create a turtle plan
|
||||
let mut plan = create_turtle();
|
||||
|
||||
// Set animation speed
|
||||
plan.set_speed(50);
|
||||
plan.right(45.0);
|
||||
plan.forward(100.0);
|
||||
plan.right(45.0);
|
||||
plan.forward(100.0);
|
||||
//plan.circle_left(100.0, 90.0, 72); // Full circle to the left
|
||||
|
||||
// Create turtle app with animation (speed = 100 pixels/sec)
|
||||
let mut app = TurtleApp::new().with_commands(plan.build(), 10.0);
|
||||
let mut app = TurtleApp::new().with_commands(plan.build());
|
||||
|
||||
// Main loop
|
||||
loop {
|
||||
|
||||
@@ -23,22 +23,23 @@ async fn main() {
|
||||
let mut plan = create_turtle();
|
||||
|
||||
// Position turtle
|
||||
plan.set_speed(10);
|
||||
plan.pen_up();
|
||||
plan.backward(150.0);
|
||||
|
||||
plan.pen_down();
|
||||
plan.set_speed(10000);
|
||||
|
||||
// Draw Koch snowflake (triangle of Koch curves)
|
||||
for _ in 0..3 {
|
||||
koch(4, &mut plan, 300.0);
|
||||
plan.right(120.0);
|
||||
plan.set_speed(1000);
|
||||
}
|
||||
|
||||
plan.hide(); // Hide turtle when done
|
||||
|
||||
// Create app with animation
|
||||
let mut app = TurtleApp::new().with_commands(plan.build(), 1000.0);
|
||||
let mut app = TurtleApp::new().with_commands(plan.build());
|
||||
|
||||
loop {
|
||||
clear_background(WHITE);
|
||||
|
||||
@@ -58,8 +58,8 @@ async fn main() {
|
||||
|
||||
nikolaus(&mut plan, 100.0);
|
||||
|
||||
// Create turtle app with animation (speed = 100 pixels/sec)
|
||||
let mut app = TurtleApp::new().with_commands(plan.build(), 100.0);
|
||||
// Create turtle app with animation
|
||||
let mut app = TurtleApp::new().with_commands(plan.build());
|
||||
|
||||
// Main loop
|
||||
loop {
|
||||
|
||||
@@ -31,8 +31,11 @@ async fn main() {
|
||||
plan.shape(ShapeType::Arrow);
|
||||
plan.forward(100.0);
|
||||
|
||||
// Set animation speed
|
||||
plan.set_speed(50);
|
||||
|
||||
// Create turtle app with animation (speed = 100 pixels/sec for slower animation)
|
||||
let mut app = TurtleApp::new().with_commands(plan.build(), 700.0);
|
||||
let mut app = TurtleApp::new().with_commands(plan.build());
|
||||
|
||||
// Main loop
|
||||
loop {
|
||||
|
||||
@@ -14,8 +14,11 @@ async fn main() {
|
||||
plan.forward(100.0).right(90.0);
|
||||
}
|
||||
|
||||
// Create turtle app with animation (speed = 100 pixels/sec)
|
||||
let mut app = TurtleApp::new().with_commands(plan.build(), 100.0);
|
||||
// Set animation speed
|
||||
plan.set_speed(50);
|
||||
|
||||
// Create turtle app with animation
|
||||
let mut app = TurtleApp::new().with_commands(plan.build());
|
||||
|
||||
// Main loop
|
||||
loop {
|
||||
|
||||
@@ -18,8 +18,11 @@ async fn main() {
|
||||
plan.circle_left(10.0, 72.0, 1000);
|
||||
}
|
||||
|
||||
// Set animation speed
|
||||
plan.set_speed(300);
|
||||
|
||||
// Create turtle app with animation (speed = 100 pixels/sec)
|
||||
let mut app = TurtleApp::new().with_commands(plan.build(), 100.0);
|
||||
let mut app = TurtleApp::new().with_commands(plan.build());
|
||||
|
||||
// Main loop
|
||||
loop {
|
||||
|
||||
@@ -25,8 +25,11 @@ async fn main() {
|
||||
t.pen_down();
|
||||
t.circle_right(8.0, 360.0, 12);
|
||||
|
||||
// Set animation speed
|
||||
t.set_speed(1000);
|
||||
|
||||
// Create turtle app with animation (speed = 100 pixels/sec)
|
||||
let mut app = TurtleApp::new().with_commands(t.build(), 100.0);
|
||||
let mut app = TurtleApp::new().with_commands(t.build());
|
||||
|
||||
// Main loop
|
||||
loop {
|
||||
|
||||
Reference in New Issue
Block a user