const TEXT_OFFSET_Y_SPACING: f32 = 0.4;
const TEXT_HEIGHT_SCALE: f32 = 0.1;
const ARTIST_HEIGHT_SCALE: f32 = 0.08;
+const TIMER_HEIGHT_SCALE: f32 = 0.07;
fn seconds_to_time(seconds: f64) -> String {
let seconds_int: u64 = seconds.floor() as u64;
title_transform: Transform,
timer_text: Text,
timer_transform: Transform,
+ timer_x: f32,
+ timer_y: f32,
timer: f64,
length: f64,
text_bg_mesh: Option<Mesh>,
title_transform: Transform::default(),
timer_text: Text::new("0"),
timer_transform: Transform::default(),
+ timer_x: INIT_FONT_SIZE_X,
+ timer_y: INIT_FONT_SIZE_Y,
timer: 0.0,
length: 0.0,
text_bg_mesh: None,
let text_height_limit = TEXT_HEIGHT_SCALE * screen_coords.h.abs();
let artist_height_limit = ARTIST_HEIGHT_SCALE * screen_coords.h.abs();
+ let timer_height = TIMER_HEIGHT_SCALE * screen_coords.h.abs();
let mut offset_y: f32 = screen_coords.h;
offset_y: &mut f32,
y: &mut f32,
is_string: bool,
- is_artist: bool| {
+ is_artist: bool,
+ timer_x: &mut f32,
+ timer_y: &mut f32| {
let mut current_x = INIT_FONT_SIZE_X;
let mut current_y = INIT_FONT_SIZE_Y;
let mut width: f32;
break;
}
} else {
+ let diff_scale_y = current_y / height * timer_height;
+ let current_x = current_x * diff_scale_y / current_y;
+ text.set_font(
+ Font::default(),
+ PxScale {
+ x: current_x,
+ y: diff_scale_y,
+ },
+ );
+ *timer_x = current_x;
+ *timer_y = diff_scale_y;
+ // width = text.width(ctx); // not really used after this
+ height = text.height(ctx);
break;
}
}
&mut filename_y,
true,
false,
+ &mut self.timer_x,
+ &mut self.timer_y,
);
} else {
log("filename text is empty");
&mut artist_y,
true,
true,
+ &mut self.timer_x,
+ &mut self.timer_y,
);
} else {
log("artist text is empty");
&mut title_y,
true,
false,
+ &mut self.timer_x,
+ &mut self.timer_y,
);
} else {
log("title text is empty");
&mut timer_y,
false,
false,
+ &mut self.timer_x,
+ &mut self.timer_y,
);
let filename_dimensions = self.filename_text.dimensions(ctx);
self.timer_text.set_font(
Font::default(),
PxScale {
- x: INIT_FONT_SIZE_X,
- y: INIT_FONT_SIZE_Y,
+ x: self.timer_x,
+ y: self.timer_y,
},
);