Create 'animation' file

This commit is contained in:
Dr. Dystopia 2021-08-01 22:43:41 +02:00
parent dffc91045e
commit 323e3166f5
4 changed files with 8 additions and 3 deletions

View File

@ -0,0 +1,3 @@
pub fn animation_timer(pulse: f32) -> f32 {
(pulse * 4.0/* speed factor */).cos() * 0.5 + 0.8 //y=0.5cos(4x)+0.8
}

View File

@ -3,7 +3,7 @@ use super::{
BUFF_COLOR, DEBUFF_COLOR, TEXT_COLOR,
};
use crate::{
hud::{self, BuffPosition},
hud::{self, animation::animation_timer, BuffPosition},
ui::{fonts::Fonts, ImageFrame, Tooltip, TooltipManager, Tooltipable},
GlobalState,
};
@ -104,7 +104,7 @@ impl<'a> Widget for BuffsBar<'a> {
let mut event = Vec::new();
let localized_strings = self.localized_strings;
let buffs = self.buffs;
let buff_ani = ((self.pulse * 4.0/* speed factor */).cos() * 0.5 + 0.8) + 0.5; //Animation timer
let buff_ani = animation_timer(self.pulse) + 0.5; //Animation timer
let pulsating_col = Color::Rgba(1.0, 1.0, 1.0, buff_ani);
let norm_col = Color::Rgba(1.0, 1.0, 1.0, 1.0);
let buff_position = self.global_state.settings.interface.buff_position;

View File

@ -4,6 +4,7 @@ use super::{
};
use crate::{
game_input::GameInput,
hud::animation::animation_timer,
ui::{fonts::Fonts, ImageFrame, Tooltip, TooltipManager, Tooltipable},
window::KeyMouse,
GlobalState,
@ -356,7 +357,7 @@ impl<'a> Widget for Buttons<'a> {
}
// Unspent SP indicator
if unspent_sp {
let arrow_ani = (self.pulse * 4.0/* speed factor */).cos() * 0.5 + 0.8; //Animation timer
let arrow_ani = animation_timer(self.pulse); //Animation timer
Image::new(self.imgs.sp_indicator_arrow)
.w_h(20.0, 11.0)
.graphics_for(state.ids.spellbook_button)

View File

@ -1,3 +1,4 @@
mod animation;
mod bag;
mod buffs;
mod buttons;