Fixed scaling
This commit is contained in:
parent
4b48b7b1cf
commit
ab14a40993
27
src/main.rs
27
src/main.rs
@ -40,7 +40,8 @@ pub fn rotate_vec2(vec: Vec2, angle: f32) -> Vec2 {
|
||||
Mat2::from_angle(angle) * vec
|
||||
}
|
||||
|
||||
pub fn draw_display(pos: Vec2, size: Vec2, text: &str, font_size: f32) {
|
||||
pub fn draw_display(pos: Vec2, size: Vec2, text: &str) {
|
||||
let font_size = size.y;
|
||||
let text_center = get_text_center(text, None, font_size as u16, 1.0, 0.0);
|
||||
|
||||
draw_rectangle_ex(
|
||||
@ -59,7 +60,8 @@ pub fn draw_display(pos: Vec2, size: Vec2, text: &str, font_size: f32) {
|
||||
draw_text(text, text_pos.x, text_pos.y, font_size, SKYBLUE);
|
||||
}
|
||||
|
||||
pub fn draw_label(pos: Vec2, size: Vec2, text: &str, font_size: f32) {
|
||||
pub fn draw_label(pos: Vec2, size: Vec2, text: &str) {
|
||||
let font_size = size.y;
|
||||
let text_center = get_text_center(text, None, font_size as u16, 1.0, 0.0);
|
||||
|
||||
draw_rectangle_ex(
|
||||
@ -109,7 +111,7 @@ pub fn draw_disc(
|
||||
let mut text_pos = Vec2::new(0.0, -text_radius);
|
||||
let mut line_pos = Vec2::new(0.0, radius);
|
||||
|
||||
let font_size = 30;
|
||||
let font_size = (radius * 0.15) as u16;
|
||||
|
||||
let mut angle = start_angle;
|
||||
|
||||
@ -282,7 +284,7 @@ pub fn draw_device(ctx: &mut Context) {
|
||||
"PROPERTY OF Foghaven Guard",
|
||||
dev_x + width * 0.02,
|
||||
dev_y + height * 0.05,
|
||||
50.0,
|
||||
width * 0.06,
|
||||
RED,
|
||||
);
|
||||
|
||||
@ -367,7 +369,7 @@ pub fn draw_device(ctx: &mut Context) {
|
||||
dev_y + height * 0.05,
|
||||
TextParams {
|
||||
font: None,
|
||||
font_size: 50,
|
||||
font_size: (dev_x * 0.055) as u16,
|
||||
font_scale: 1.0,
|
||||
font_scale_aspect: 1.0,
|
||||
rotation: 10.0f32.to_radians(),
|
||||
@ -455,7 +457,6 @@ fn input_panel(ctx: &mut Context, base: Vec2, size: Vec2) {
|
||||
input_letter_disp_loc,
|
||||
input_letter_size,
|
||||
input_letter.to_string().as_str(),
|
||||
80.0,
|
||||
);
|
||||
|
||||
let input_label_pos = input_letter_disp_loc
|
||||
@ -464,7 +465,7 @@ fn input_panel(ctx: &mut Context, base: Vec2, size: Vec2) {
|
||||
input_letter_size.y * 0.25,
|
||||
);
|
||||
let input_label_size = Vec2::new(border_size.x * 0.2, border_size.y * 0.15);
|
||||
draw_label(input_label_pos, input_label_size, "INPUT", 40.0);
|
||||
draw_label(input_label_pos, input_label_size, "INPUT");
|
||||
|
||||
let index_disp_loc =
|
||||
input_letter_disp_loc + Vec2::new(0.0, input_letter_size.y + border_size.x * 0.05);
|
||||
@ -472,7 +473,6 @@ fn input_panel(ctx: &mut Context, base: Vec2, size: Vec2) {
|
||||
index_disp_loc,
|
||||
input_letter_size,
|
||||
ctx.decoder_state.outer_disc_index.to_string().as_str(),
|
||||
80.0,
|
||||
);
|
||||
|
||||
let index_label_pos = index_disp_loc
|
||||
@ -481,7 +481,7 @@ fn input_panel(ctx: &mut Context, base: Vec2, size: Vec2) {
|
||||
input_letter_size.y * 0.25,
|
||||
);
|
||||
|
||||
draw_label(index_label_pos, input_label_size, "INDEX", 40.0);
|
||||
draw_label(index_label_pos, input_label_size, "INDEX");
|
||||
|
||||
let output_disp_loc = border_pos + Vec2::new(border_size.x * 0.55, border_size.x * 0.05);
|
||||
let output_disp_size = Vec2::new(border_size.x * 0.33, border_size.y * 0.6);
|
||||
@ -496,16 +496,17 @@ fn input_panel(ctx: &mut Context, base: Vec2, size: Vec2) {
|
||||
output_disp_loc,
|
||||
output_disp_size,
|
||||
output_disp.to_string().as_str(),
|
||||
160.0,
|
||||
);
|
||||
|
||||
let output_label_size = input_label_size * 1.1;
|
||||
|
||||
let output_disp_label_loc = output_disp_loc
|
||||
+ Vec2::new(
|
||||
output_disp_size.x / 2.0 - input_label_size.x / 2.0,
|
||||
output_disp_size.x / 2.0 - output_label_size.x / 2.0,
|
||||
output_disp_size.y + size.y * 0.01,
|
||||
);
|
||||
|
||||
draw_label(output_disp_label_loc, input_label_size, "OUTPUT", 40.0);
|
||||
draw_label(output_disp_label_loc, output_label_size, "OUTPUT");
|
||||
|
||||
let switch_pos = border_pos + border_size * 0.5;
|
||||
let switch_size = Vec2::new(border_size.x * 0.05, border_size.y * 0.25);
|
||||
@ -513,13 +514,11 @@ fn input_panel(ctx: &mut Context, base: Vec2, size: Vec2) {
|
||||
switch_pos + Vec2::new(-border_size.x * 0.05 * 0.5, switch_size.y),
|
||||
Vec2::new(border_size.x * 0.05, border_size.x * 0.05),
|
||||
"D",
|
||||
40.0,
|
||||
);
|
||||
draw_label(
|
||||
switch_pos + Vec2::new(-border_size.x * 0.05 * 0.5, -switch_size.y * 1.5),
|
||||
Vec2::new(border_size.x * 0.05, border_size.x * 0.05),
|
||||
"E",
|
||||
40.0,
|
||||
);
|
||||
|
||||
if draw_switch(switch_pos, switch_size, ctx.mode == Mode::Encode) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user