Compare commits
5
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6d880cb7fb
|
||
|
|
83ad2068e0
|
||
|
|
3908e6d913
|
||
|
|
27728fc431
|
||
|
|
6f591627be
|
@@ -0,0 +1,2 @@
|
||||
[target.wasm32-unknown-unknown]
|
||||
rustflags = ['--cfg', 'getrandom_backend="wasm_js"']
|
||||
Generated
+4
@@ -953,9 +953,11 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "73fea8450eea4bac3940448fb7ae50d91f034f941199fcd9d909a5a07aa455f0"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"js-sys",
|
||||
"libc",
|
||||
"r-efi",
|
||||
"wasi 0.14.2+wasi-0.2.4",
|
||||
"wasm-bindgen",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -1350,6 +1352,7 @@ dependencies = [
|
||||
"egui_glow 0.31.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"env_logger",
|
||||
"eyre",
|
||||
"getrandom 0.3.2",
|
||||
"half",
|
||||
"insta",
|
||||
"log",
|
||||
@@ -1357,6 +1360,7 @@ dependencies = [
|
||||
"rfd",
|
||||
"serde",
|
||||
"wasm-bindgen-futures",
|
||||
"web-sys",
|
||||
"zerocopy 0.8.25",
|
||||
]
|
||||
|
||||
|
||||
@@ -30,9 +30,12 @@ base64 = "0.22.1"
|
||||
|
||||
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
|
||||
env_logger = "0.11.8"
|
||||
rand = "0.9.1"
|
||||
|
||||
[target.'cfg(target_arch = "wasm32")'.dependencies]
|
||||
getrandom = { version = "0.3", features = ["wasm_js"] }
|
||||
wasm-bindgen-futures = "0.4.50"
|
||||
web-sys = "0.3.77"
|
||||
|
||||
[patch.crates-io]
|
||||
egui = { git = "https://github.com/emilk/egui", rev = "f2ce6424f3a32f47308fb9871d540c01377b2cd9" }
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
+4
-8
@@ -2,7 +2,6 @@ use std::{
|
||||
fs,
|
||||
path::PathBuf,
|
||||
sync::{Arc, mpsc},
|
||||
thread,
|
||||
};
|
||||
|
||||
use crate::{file_editor::FileEditor, preferences::Preferences, util::GuiSender};
|
||||
@@ -10,9 +9,8 @@ use egui::{
|
||||
Align, Button, Color32, FontData, FontDefinitions, PointerButton, RichText, ScrollArea, Stroke,
|
||||
};
|
||||
|
||||
/// We derive Deserialize/Serialize so we can persist app state on shutdown.
|
||||
#[derive(serde::Deserialize, serde::Serialize)]
|
||||
#[serde(default)] // if we add new fields, give them default values when deserializing old state
|
||||
#[serde(default)]
|
||||
pub struct App {
|
||||
preferences: Preferences,
|
||||
|
||||
@@ -141,8 +139,6 @@ impl App {
|
||||
Stroke::new(1.0, Color32::from_rgb(200, 200, 200));
|
||||
});
|
||||
|
||||
// Load previous app state (if any).
|
||||
// Note that you must enable the `persistence` feature for this to work.
|
||||
if let Some(storage) = cc.storage {
|
||||
return eframe::get_value(storage, eframe::APP_KEY).unwrap_or_default();
|
||||
}
|
||||
@@ -197,8 +193,6 @@ impl eframe::App for App {
|
||||
//});
|
||||
|
||||
egui::TopBottomPanel::top("top_panel").show(ctx, |ui| {
|
||||
// The top panel is often a good place for a menu bar:
|
||||
|
||||
egui::containers::menu::Bar::new().ui(ui, |ui| {
|
||||
// NOTE: no File->Quit on web pages!
|
||||
ui.menu_button("Menu ⚙", |ui| {
|
||||
@@ -209,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 };
|
||||
@@ -268,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()
|
||||
|
||||
+1
-1
@@ -49,7 +49,7 @@ fn main() {
|
||||
.start(
|
||||
canvas,
|
||||
web_options,
|
||||
Box::new(|cc| Ok(Box::new(eframe_template::TemplateApp::new(cc)))),
|
||||
Box::new(|cc| Ok(Box::new(inkr::App::new(cc)))),
|
||||
)
|
||||
.await;
|
||||
|
||||
|
||||
+7
-4
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user