mirror of
https://github.com/ricoriedel/wipe.git
synced 2024-11-23 00:16:38 +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
|
## Showcase
|
||||||
[![Circle](doc/circle.gif)]()
|
[![Circle](doc/circle.gif)]()
|
||||||
[![Rhombus](doc/rhombus.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 circle;
|
||||||
pub mod rotation;
|
pub mod sonar;
|
||||||
pub mod rhombus;
|
pub mod rhombus;
|
||||||
|
|
||||||
use crate::vec::Vector;
|
use crate::vec::Vector;
|
||||||
|
@ -6,11 +6,12 @@ const TWO_PI: f32 = PI * 2.0;
|
|||||||
const THICKNESS: f32 = TWO_PI * 0.1;
|
const THICKNESS: f32 = TWO_PI * 0.1;
|
||||||
const FULL_ROTATION: f32 = TWO_PI + THICKNESS * 2.0;
|
const FULL_ROTATION: f32 = TWO_PI + THICKNESS * 2.0;
|
||||||
|
|
||||||
pub struct RotationAnimation {
|
/// A sonar like animation.
|
||||||
|
pub struct SonarAnimation {
|
||||||
center: Vector
|
center: Vector
|
||||||
}
|
}
|
||||||
|
|
||||||
impl RotationAnimation {
|
impl SonarAnimation {
|
||||||
pub fn new(size: Vector) -> Self {
|
pub fn new(size: Vector) -> Self {
|
||||||
Self {
|
Self {
|
||||||
center: size.center()
|
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 {
|
fn sample(&self, step: f32, pos: Vector) -> f32 {
|
||||||
let angle = FULL_ROTATION * step - PI - THICKNESS;
|
let angle = FULL_ROTATION * step - PI - THICKNESS;
|
||||||
let pos_angle = (pos - self.center).angle();
|
let pos_angle = (pos - self.center).angle();
|
||||||
@ -33,7 +34,7 @@ mod test {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn sample() {
|
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_1 = anim.sample(0.3, Vector::new(16.0, 3.0));
|
||||||
let sample_2 = anim.sample(0.7, Vector::new(22.0, 2.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::Animation;
|
||||||
use crate::animation::circle::CircleAnimation;
|
use crate::animation::circle::CircleAnimation;
|
||||||
use crate::animation::rhombus::RhombusAnimation;
|
use crate::animation::rhombus::RhombusAnimation;
|
||||||
use crate::animation::rotation::RotationAnimation;
|
use crate::animation::sonar::SonarAnimation;
|
||||||
use crate::char::SimpleCharSampler;
|
use crate::char::SimpleCharSampler;
|
||||||
use crate::choose::{Chooser, Collection};
|
use crate::choose::{Chooser, Collection};
|
||||||
use crate::color::{ColorSampler, SimpleColorSampler};
|
use crate::color::{ColorSampler, SimpleColorSampler};
|
||||||
@ -53,7 +53,7 @@ macro_rules! options {
|
|||||||
options!(AnimationType {
|
options!(AnimationType {
|
||||||
Circle,
|
Circle,
|
||||||
Rhombus,
|
Rhombus,
|
||||||
Rotation,
|
Sonar,
|
||||||
});
|
});
|
||||||
|
|
||||||
options!(ColorType {
|
options!(ColorType {
|
||||||
@ -170,7 +170,7 @@ fn create_animation(animation: AnimationType, size: Vector) -> Box<dyn Animation
|
|||||||
match animation {
|
match animation {
|
||||||
AnimationType::Circle => Box::new(CircleAnimation::new(size)),
|
AnimationType::Circle => Box::new(CircleAnimation::new(size)),
|
||||||
AnimationType::Rhombus => Box::new(RhombusAnimation::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::Circle, size);
|
||||||
create_animation(AnimationType::Rhombus, size);
|
create_animation(AnimationType::Rhombus, size);
|
||||||
create_animation(AnimationType::Rotation, size);
|
create_animation(AnimationType::Sonar, size);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
Loading…
Reference in New Issue
Block a user