mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-09-21 07:28:12 +08:00
Brush tool live preview (#1116)
* Disable vector preview for brush tool * Fix brush preview * Fix warping * Left and right square brackets to change size * Add linear interpolation * Modfiy existing selected brush layer * Resolve warnings --------- Co-authored-by: Dennis Kobert <dennis@kobert.dev> Co-authored-by: Keavon Chambers <keavon@keavon.com>
This commit is contained in:
committed by
Keavon Chambers
co-authored by
Dennis Kobert
Keavon Chambers
parent
69f6ed3a11
commit
f271964bf8
@@ -32,7 +32,7 @@ pub fn set_random_seed(seed: u64) {
|
||||
/// This avoids creating a json with a list millions of numbers long.
|
||||
#[wasm_bindgen(module = "@graphite/wasm-communication/editor")]
|
||||
extern "C" {
|
||||
fn updateImage(path: Vec<u64>, mime: String, imageData: &[u8], document_id: u64);
|
||||
fn updateImage(path: Vec<u64>, mime: String, imageData: &[u8], transform: js_sys::Float64Array, document_id: u64);
|
||||
fn fetchImage(path: Vec<u64>, mime: String, document_id: u64, identifier: String);
|
||||
//fn dispatchTauri(message: String) -> String;
|
||||
fn dispatchTauri(message: String);
|
||||
@@ -114,7 +114,16 @@ impl JsEditorHandle {
|
||||
if let FrontendMessage::UpdateImageData { document_id, image_data } = message {
|
||||
for image in image_data {
|
||||
#[cfg(not(feature = "tauri"))]
|
||||
updateImage(image.path, image.mime, &image.image_data, document_id);
|
||||
{
|
||||
let transform = if let Some(transform_val) = image.transform {
|
||||
let transform = js_sys::Float64Array::new_with_length(6);
|
||||
transform.copy_from(&transform_val);
|
||||
transform
|
||||
} else {
|
||||
js_sys::Float64Array::default()
|
||||
};
|
||||
updateImage(image.path, image.mime, &image.image_data, transform, document_id);
|
||||
}
|
||||
#[cfg(feature = "tauri")]
|
||||
fetchImage(image.path.clone(), image.mime, document_id, format!("http://localhost:3001/image/{:?}_{}", &image.path, document_id));
|
||||
}
|
||||
@@ -495,15 +504,22 @@ impl JsEditorHandle {
|
||||
|
||||
/// Sends the blob URL generated by JS to the Image layer
|
||||
#[wasm_bindgen(js_name = setImageBlobURL)]
|
||||
pub fn set_image_blob_url(&self, document_id: u64, layer_path: Vec<LayerId>, blob_url: String, width: f64, height: f64) {
|
||||
pub fn set_image_blob_url(&self, document_id: u64, layer_path: Vec<LayerId>, blob_url: String, width: f64, height: f64, transform: Option<js_sys::Float64Array>) {
|
||||
let resolution = (width, height);
|
||||
let message = PortfolioMessage::SetImageBlobUrl {
|
||||
document_id,
|
||||
layer_path,
|
||||
layer_path: layer_path.clone(),
|
||||
blob_url,
|
||||
resolution,
|
||||
};
|
||||
self.dispatch(message);
|
||||
|
||||
if let Some(array) = transform.filter(|array| array.length() == 6) {
|
||||
let mut transform: [f64; 6] = [0.; 6];
|
||||
array.copy_to(&mut transform);
|
||||
let message = document_legacy::Operation::SetLayerTransform { path: layer_path, transform };
|
||||
self.dispatch(message);
|
||||
}
|
||||
}
|
||||
|
||||
/// Sends the blob URL generated by JS to the Imaginate layer in the respective document
|
||||
|
||||
Reference in New Issue
Block a user