Remove math::TAU and use std::f32::consts::TAU instead

This commit is contained in:
Emil Ernerfeldt 2020-12-27 11:24:08 +01:00
parent 958fc2753a
commit 442b876cb5
8 changed files with 7 additions and 10 deletions

View file

@ -109,6 +109,7 @@ pub fn paint_icon(ui: &mut Ui, openness: f32, response: &Response) {
// Draw a pointy triangle arrow:
let rect = Rect::from_center_size(rect.center(), vec2(rect.width(), rect.height()) * 0.75);
let mut points = vec![rect.left_top(), rect.right_top(), rect.center_bottom()];
use std::f32::consts::TAU;
let rotation = Rot2::from_angle(remap(openness, 0.0..=1.0, -TAU / 4.0..=0.0));
for p in &mut points {
*p = rect.center() + rotation * (*p - rect.center());

View file

@ -44,7 +44,7 @@ impl View for DancingStrings {
.map(|i| {
let t = i as f32 / (n as f32);
let amp = (time as f32 * speed * mode).sin() / mode;
let y = amp * (t * math::TAU / 2.0 * mode).sin();
let y = amp * (t * std::f32::consts::TAU / 2.0 * mode).sin();
pos2(
lerp(rect.x_range(), t),

View file

@ -87,6 +87,7 @@ impl DemoWindow {
.show(ui, |ui| {
ui.horizontal(|ui| {
ui.label("You can pretty easily paint your own small icons:");
use std::f32::consts::TAU;
let response = ui.allocate_response(Vec2::splat(16.0), Sense::hover());
let painter = ui.painter();
let c = response.rect.center();

View file

@ -1,4 +1,5 @@
use crate::{containers::*, widgets::*, *};
use std::f32::consts::TAU;
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
#[cfg_attr(feature = "serde", serde(default))]

View file

@ -35,7 +35,7 @@ impl Default for Widgets {
radio: Enum::First,
count: 0,
sliders: Default::default(),
angle: TAU / 3.0,
angle: std::f32::consts::TAU / 3.0,
color: (Rgba::new(0.0, 1.0, 0.5, 1.0) * 0.75).into(),
single_line_text_input: "Hello World!".to_owned(),
multiline_text_input: "Text can both be so wide that it needs a line break, but you can also add manual line break by pressing enter, creating new paragraphs.\nThis is the start of the next paragraph.\n\nClick me to edit me!".to_owned(),

View file

@ -114,13 +114,6 @@ pub fn ease_in_ease_out(t: f32) -> f32 {
3.0 * t * t - 2.0 * t * t * t
}
/// The circumference of a circle divided by its radius.
///
/// Represents one turn in radian angles. Equal to `2 * pi`.
///
/// See <https://tauday.com/>
pub const TAU: f32 = 2.0 * std::f32::consts::PI;
/// Round a value to the given number of decimal places.
pub fn round_to_decimals(value: f64, decimal_places: usize) -> f64 {
// This is a stupid way of doing this, but stupid works.

View file

@ -12,6 +12,7 @@ use {
PaintCmd, Stroke,
},
crate::math::*,
std::f32::consts::TAU,
};
/// What texture to use in a `Triangles` mesh.

View file

@ -232,7 +232,7 @@ impl Painter {
/// Show an arrow starting at `origin` and going in the direction of `vec`, with the length `vec.length()`.
pub fn arrow(&self, origin: Pos2, vec: Vec2, stroke: Stroke) {
use crate::math::*;
let rot = Rot2::from_angle(TAU / 10.0);
let rot = Rot2::from_angle(std::f32::consts::TAU / 10.0);
let tip_length = vec.length() / 4.0;
let tip = origin + vec;
let dir = vec.normalized();