Layer and grid snapping systems (#1521)

* Grid overlays

* Rectangle tool basic snapping

* Fix bezier demos

* Fix bézier crate tests

* Constrained snapping for circle & shape tool

* Line tool snapping

* Pen tool snapping

* Path tool snapping

* Snapping whilst dragging layers (not constrained)

* Constrained drag

* Resize snapping

* Normal and tangent

* Cleanup

* Grid snapping

* Grid snapping

* Fix imports

* Fix bug in artboard tool

* Fix hang on 0 size grid spacing

* Fix NaN when scaling

* Polishing

---------

Co-authored-by: Keavon Chambers <keavon@keavon.com>
This commit is contained in:
0HyperCube
2024-01-13 14:32:10 +00:00
committed by GitHub
parent 78a1bb17cd
commit 456ca170a4
40 changed files with 2170 additions and 475 deletions

View File

@@ -26,6 +26,7 @@ use wasm_bindgen::{Clamped, JsCast};
use web_sys::window;
use web_sys::{CanvasRenderingContext2d, HtmlCanvasElement};
#[cfg(any(feature = "resvg", feature = "vello"))]
pub struct Canvas(CanvasRenderingContext2d);
#[derive(Debug, Default)]
@@ -284,7 +285,10 @@ fn decode_image_node<'a: 'input>(data: Arc<[u8]>) -> ImageFrame<Color> {
pub use graph_craft::document::value::RenderOutput;
pub struct RenderNode<Data, Surface, Parameter> {
data: Data,
#[cfg(any(feature = "resvg", feature = "vello"))]
surface_handle: Surface,
#[cfg(not(any(feature = "resvg", feature = "vello")))]
surface_handle: PhantomData<Surface>,
parameter: PhantomData<Parameter>,
}
@@ -417,10 +421,13 @@ where
}
#[automatically_derived]
impl<Data, Surface, Parameter> RenderNode<Data, Surface, Parameter> {
pub const fn new(data: Data, surface_handle: Surface) -> Self {
pub fn new(data: Data, surface_handle: Surface) -> Self {
Self {
data,
#[cfg(any(feature = "resvg", feature = "vello"))]
surface_handle,
#[cfg(not(any(feature = "resvg", feature = "vello")))]
surface_handle: PhantomData,
parameter: PhantomData,
}
}