Make it run in wasm

This commit is contained in:
2025-06-12 20:38:33 +02:00
parent 3908e6d913
commit 83ad2068e0
5 changed files with 19 additions and 6 deletions

View File

@ -2,7 +2,6 @@ use std::{
fs,
path::PathBuf,
sync::{Arc, mpsc},
thread,
};
use crate::{file_editor::FileEditor, preferences::Preferences, util::GuiSender};
@ -204,9 +203,10 @@ impl eframe::App for App {
self.open_tab(Tab::File(file));
}
#[cfg(not(target_arch = "wasm32"))]
if ui.button("Open File").clicked() {
let actions_tx = self.actions_tx(ui.ctx());
thread::spawn(move || {
std::thread::spawn(move || {
let file = rfd::FileDialog::new().pick_file();
let Some(file_path) = file else { return };
@ -263,6 +263,7 @@ impl eframe::App for App {
}
}
#[cfg(not(target_arch = "wasm32"))]
if ui
.add_enabled(open_file.is_some(), Button::new("Save As"))
.clicked()

View File

@ -3,7 +3,6 @@ use std::{
iter, mem,
str::FromStr,
sync::Arc,
time::Instant,
};
use base64::{Engine, prelude::BASE64_STANDARD};
@ -436,7 +435,8 @@ impl Handwriting {
self.refresh_texture = false;
let start_time = Instant::now();
#[cfg(not(target_arch = "wasm32"))]
let start_time = std::time::Instant::now();
let mut tesselator = Tessellator::new(
mesh_context.pixels_per_point,
@ -468,8 +468,11 @@ impl Handwriting {
self.image = rasterize::<StrokeBlendMode>(px_x, px_y, point_to_pixel, triangles);
texture.set(self.image.clone(), Default::default());
let elapsed = start_time.elapsed();
println!("refreshed mesh in {:.3}s", elapsed.as_secs_f32());
#[cfg(not(target_arch = "wasm32"))]
{
let elapsed = start_time.elapsed();
println!("refreshed mesh in {:.3}s", elapsed.as_secs_f32());
}
}
pub fn ui(&mut self, style: &HandwritingStyle, ui: &mut Ui) {