Remove math::TAU and use std::f32::consts::TAU instead
This commit is contained in:
parent
958fc2753a
commit
442b876cb5
8 changed files with 7 additions and 10 deletions
|
@ -109,6 +109,7 @@ pub fn paint_icon(ui: &mut Ui, openness: f32, response: &Response) {
|
||||||
// Draw a pointy triangle arrow:
|
// Draw a pointy triangle arrow:
|
||||||
let rect = Rect::from_center_size(rect.center(), vec2(rect.width(), rect.height()) * 0.75);
|
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()];
|
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));
|
let rotation = Rot2::from_angle(remap(openness, 0.0..=1.0, -TAU / 4.0..=0.0));
|
||||||
for p in &mut points {
|
for p in &mut points {
|
||||||
*p = rect.center() + rotation * (*p - rect.center());
|
*p = rect.center() + rotation * (*p - rect.center());
|
||||||
|
|
|
@ -44,7 +44,7 @@ impl View for DancingStrings {
|
||||||
.map(|i| {
|
.map(|i| {
|
||||||
let t = i as f32 / (n as f32);
|
let t = i as f32 / (n as f32);
|
||||||
let amp = (time as f32 * speed * mode).sin() / mode;
|
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(
|
pos2(
|
||||||
lerp(rect.x_range(), t),
|
lerp(rect.x_range(), t),
|
||||||
|
|
|
@ -87,6 +87,7 @@ impl DemoWindow {
|
||||||
.show(ui, |ui| {
|
.show(ui, |ui| {
|
||||||
ui.horizontal(|ui| {
|
ui.horizontal(|ui| {
|
||||||
ui.label("You can pretty easily paint your own small icons:");
|
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 response = ui.allocate_response(Vec2::splat(16.0), Sense::hover());
|
||||||
let painter = ui.painter();
|
let painter = ui.painter();
|
||||||
let c = response.rect.center();
|
let c = response.rect.center();
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
use crate::{containers::*, widgets::*, *};
|
use crate::{containers::*, widgets::*, *};
|
||||||
|
use std::f32::consts::TAU;
|
||||||
|
|
||||||
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
|
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
|
||||||
#[cfg_attr(feature = "serde", serde(default))]
|
#[cfg_attr(feature = "serde", serde(default))]
|
||||||
|
|
|
@ -35,7 +35,7 @@ impl Default for Widgets {
|
||||||
radio: Enum::First,
|
radio: Enum::First,
|
||||||
count: 0,
|
count: 0,
|
||||||
sliders: Default::default(),
|
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(),
|
color: (Rgba::new(0.0, 1.0, 0.5, 1.0) * 0.75).into(),
|
||||||
single_line_text_input: "Hello World!".to_owned(),
|
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(),
|
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(),
|
||||||
|
|
|
@ -114,13 +114,6 @@ pub fn ease_in_ease_out(t: f32) -> f32 {
|
||||||
3.0 * t * t - 2.0 * t * t * t
|
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.
|
/// Round a value to the given number of decimal places.
|
||||||
pub fn round_to_decimals(value: f64, decimal_places: usize) -> f64 {
|
pub fn round_to_decimals(value: f64, decimal_places: usize) -> f64 {
|
||||||
// This is a stupid way of doing this, but stupid works.
|
// This is a stupid way of doing this, but stupid works.
|
||||||
|
|
|
@ -12,6 +12,7 @@ use {
|
||||||
PaintCmd, Stroke,
|
PaintCmd, Stroke,
|
||||||
},
|
},
|
||||||
crate::math::*,
|
crate::math::*,
|
||||||
|
std::f32::consts::TAU,
|
||||||
};
|
};
|
||||||
|
|
||||||
/// What texture to use in a `Triangles` mesh.
|
/// What texture to use in a `Triangles` mesh.
|
||||||
|
|
|
@ -232,7 +232,7 @@ impl Painter {
|
||||||
/// Show an arrow starting at `origin` and going in the direction of `vec`, with the length `vec.length()`.
|
/// 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) {
|
pub fn arrow(&self, origin: Pos2, vec: Vec2, stroke: Stroke) {
|
||||||
use crate::math::*;
|
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_length = vec.length() / 4.0;
|
||||||
let tip = origin + vec;
|
let tip = origin + vec;
|
||||||
let dir = vec.normalized();
|
let dir = vec.normalized();
|
||||||
|
|
Loading…
Reference in a new issue