GraphiteEditor / Graphite

2D vector & raster editor that melds traditional layers & tools with a modern node-based, non-destructive, procedural workflow.
https://graphite.rs
Apache License 2.0
7.29k stars 385 forks source link

Creating empty, infinite canvas causes error #1781

Closed Comeza closed 1 week ago

Comeza commented 2 weeks ago

image

Provided error in node graph:

Multiple implementations found (EditorApi<WasmApplicationIo>, (() -> GraphicGroup), (() -> Arc<SurfaceHandle<HtmlCanvasElement>>)):
[
    node(EditorApi<WasmApplicationIo>, (Footprint -> GraphicGroup), (() -> Arc<SurfaceHandle<HtmlCanvasElement>>)) -> RenderOutput,
    node(EditorApi<WasmApplicationIo>, (() -> GraphicGroup), (() -> Arc<SurfaceHandle<HtmlCanvasElement>>)) -> RenderOutput,
]

Steps:

  1. Open https://editor.graphite.rs/
  2. Create new document with infinite canvas enabled.
  3. Error
Keavon commented 2 weeks ago

In master (https://dev.graphite.rs) the issue is mostly fixed, but when there's no output at all, it doesn't show the white background like it should. Once you draw something like a shape, it correctly adds the white background though. @adamgerhant is that something you could take a quick look at fixing? Thanks!

0HyperCube commented 2 weeks ago

The reason for the no white background is that the artboard group always returns true for an artboard, even if it is empty:

https://github.com/GraphiteEditor/Graphite/blob/cf01f522a8b57bfd625f15a10ae6b2812ed4c0a4/node-graph/gcore/src/graphic_element/renderer.rs#L473-L475

adamgerhant commented 2 weeks ago

When the Exports node is disconnected (for example when creating an infinite canvas), it is set to NodeInput::Value, where the tagged value is graphene_core::ArtboardGroup::EMPTY. To display the white background, contains_artboard should check if the ArtboardGroup has no artboards

fn contains_artboard(&self) -> bool {
    self.artboards.len() > 0
}
0HyperCube commented 1 week ago

This was resolved as part of #1768.