mirror of
https://github.com/ricoriedel/wipe.git
synced 2024-12-23 06:36:42 +00:00
Rename rotation to sonar
This commit is contained in:
parent
96390b09b9
commit
f18d09b5c4
@ -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)]()
|
||||
|
Before Width: | Height: | Size: 223 KiB After Width: | Height: | Size: 223 KiB |
@ -1,5 +1,5 @@
|
||||
pub mod circle;
|
||||
pub mod rotation;
|
||||
pub mod sonar;
|
||||
pub mod rhombus;
|
||||
|
||||
use crate::vec::Vector;
|
||||
|
@ -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));
|
@ -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<dyn Animation
|
||||
match animation {
|
||||
AnimationType::Circle => 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]
|
||||
|
Loading…
Reference in New Issue
Block a user