From f18d09b5c425c781fc1b120b839535781cb7b91e Mon Sep 17 00:00:00 2001 From: Nicolas <> Date: Fri, 15 Apr 2022 07:58:08 +0200 Subject: [PATCH] Rename rotation to sonar --- README.md | 2 +- doc/{rotation.gif => sonar.gif} | Bin src/animation/mod.rs | 2 +- src/animation/{rotation.rs => sonar.rs} | 9 +++++---- src/main.rs | 8 ++++---- 5 files changed, 11 insertions(+), 10 deletions(-) rename doc/{rotation.gif => sonar.gif} (100%) rename src/animation/{rotation.rs => sonar.rs} (84%) diff --git a/README.md b/README.md index 5585cd4..b1effae 100644 --- a/README.md +++ b/README.md @@ -15,4 +15,4 @@ Note that some parameters like `--color` can be specified multiple times with di ## Showcase [![Circle](doc/circle.gif)]() [![Rhombus](doc/rhombus.gif)]() -[![Rotation](doc/rotation.gif)]() +[![Rotation](doc/sonar.gif)]() diff --git a/doc/rotation.gif b/doc/sonar.gif similarity index 100% rename from doc/rotation.gif rename to doc/sonar.gif diff --git a/src/animation/mod.rs b/src/animation/mod.rs index e7f3b2e..00b76ac 100644 --- a/src/animation/mod.rs +++ b/src/animation/mod.rs @@ -1,5 +1,5 @@ pub mod circle; -pub mod rotation; +pub mod sonar; pub mod rhombus; use crate::vec::Vector; diff --git a/src/animation/rotation.rs b/src/animation/sonar.rs similarity index 84% rename from src/animation/rotation.rs rename to src/animation/sonar.rs index b8a19d4..c30f6d1 100644 --- a/src/animation/rotation.rs +++ b/src/animation/sonar.rs @@ -6,11 +6,12 @@ const TWO_PI: f32 = PI * 2.0; const THICKNESS: f32 = TWO_PI * 0.1; const FULL_ROTATION: f32 = TWO_PI + THICKNESS * 2.0; -pub struct RotationAnimation { +/// A sonar like animation. +pub struct SonarAnimation { center: Vector } -impl RotationAnimation { +impl SonarAnimation { pub fn new(size: Vector) -> Self { Self { center: size.center() @@ -18,7 +19,7 @@ impl RotationAnimation { } } -impl Animation for RotationAnimation { +impl Animation for SonarAnimation { fn sample(&self, step: f32, pos: Vector) -> f32 { let angle = FULL_ROTATION * step - PI - THICKNESS; let pos_angle = (pos - self.center).angle(); @@ -33,7 +34,7 @@ mod test { #[test] fn sample() { - let anim = RotationAnimation::new(Vector::new(30.0, 10.0)); + let anim = SonarAnimation::new(Vector::new(30.0, 10.0)); let sample_1 = anim.sample(0.3, Vector::new(16.0, 3.0)); let sample_2 = anim.sample(0.7, Vector::new(22.0, 2.0)); diff --git a/src/main.rs b/src/main.rs index 6d2a2e0..b5e90ce 100644 --- a/src/main.rs +++ b/src/main.rs @@ -7,7 +7,7 @@ use rand::rngs::OsRng; use crate::animation::Animation; use crate::animation::circle::CircleAnimation; use crate::animation::rhombus::RhombusAnimation; -use crate::animation::rotation::RotationAnimation; +use crate::animation::sonar::SonarAnimation; use crate::char::SimpleCharSampler; use crate::choose::{Chooser, Collection}; use crate::color::{ColorSampler, SimpleColorSampler}; @@ -53,7 +53,7 @@ macro_rules! options { options!(AnimationType { Circle, Rhombus, - Rotation, + Sonar, }); options!(ColorType { @@ -170,7 +170,7 @@ fn create_animation(animation: AnimationType, size: Vector) -> Box Box::new(CircleAnimation::new(size)), AnimationType::Rhombus => Box::new(RhombusAnimation::new(size)), - AnimationType::Rotation => Box::new(RotationAnimation::new(size)), + AnimationType::Sonar => Box::new(SonarAnimation::new(size)), } } @@ -262,7 +262,7 @@ mod test { create_animation(AnimationType::Circle, size); create_animation(AnimationType::Rhombus, size); - create_animation(AnimationType::Rotation, size); + create_animation(AnimationType::Sonar, size); } #[test]