mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-09-19 10:58:04 +08:00
Implement basic circle stamping (#53)
This commit is contained in:
@@ -17,7 +17,9 @@
|
||||
@mousedown="canvasMouseDown"
|
||||
@mouseup="canvasMouseUp"
|
||||
@mousemove="canvasMouseMove"
|
||||
></LayoutCol>
|
||||
>
|
||||
<svg></svg>
|
||||
</LayoutCol>
|
||||
</LayoutRow>
|
||||
</LayoutCol>
|
||||
</template>
|
||||
@@ -65,6 +67,11 @@
|
||||
.canvas {
|
||||
background: #111;
|
||||
flex: 1 1 100%;
|
||||
|
||||
svg {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
export function update_canvas() {
|
||||
console.log("update_canvas")
|
||||
export function update_canvas(svg) {
|
||||
document.querySelector(".canvas svg").innerHTML = svg;
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@ use std::cell::RefCell;
|
||||
use wasm_bindgen::prelude::*;
|
||||
|
||||
// the thread_local macro provides a way to initialize static variables with non-constant functions
|
||||
thread_local! {pub static EDITOR_STATE: RefCell<Editor> = RefCell::new(Editor::new(Box::new(handle_response)))}
|
||||
thread_local! { pub static EDITOR_STATE: RefCell<Editor> = RefCell::new(Editor::new(Box::new(handle_response))) }
|
||||
|
||||
#[wasm_bindgen(start)]
|
||||
pub fn init() {
|
||||
@@ -18,13 +18,13 @@ pub fn init() {
|
||||
|
||||
fn handle_response(response: Response) {
|
||||
match response {
|
||||
Response::UpdateCanvas => update_canvas(),
|
||||
Response::UpdateCanvas { document } => update_canvas(document),
|
||||
}
|
||||
}
|
||||
|
||||
#[wasm_bindgen(module = "/../src/wasm-callback-processor.js")]
|
||||
extern "C" {
|
||||
fn update_canvas();
|
||||
fn update_canvas(svg: String);
|
||||
}
|
||||
|
||||
#[wasm_bindgen]
|
||||
|
||||
@@ -35,7 +35,7 @@ pub fn on_mouse_down(x: u32, y: u32, mouse_keys: u8) -> Result<(), JsValue> {
|
||||
#[wasm_bindgen]
|
||||
pub fn on_mouse_up(x: u32, y: u32, mouse_keys: u8) -> Result<(), JsValue> {
|
||||
let mouse_keys = events::MouseKeys::from_bits(mouse_keys).expect("invalid modifier keys");
|
||||
let ev = events::Event::MouseDown(events::MouseState {
|
||||
let ev = events::Event::MouseUp(events::MouseState {
|
||||
position: events::CanvasPosition { x, y },
|
||||
mouse_keys,
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user