-
-
Notifications
You must be signed in to change notification settings - Fork 1k
Fix Exports having 0 layers #3618
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Fix Exports having 0 layers #3618
Conversation
…nto fix/no-layer-exports
| let non_layer_export_bounds = self | ||
| .document_network() | ||
| .exports | ||
| .iter() | ||
| .filter_map(|export| { | ||
| if let NodeInput::Node { node_id, .. } = export { | ||
| if !self.is_layer(node_id, &[]) { | ||
| return self.document_metadata().bounding_box_document(LayerNodeIdentifier::new_unchecked(*node_id)); | ||
| } | ||
| } | ||
| None | ||
| }) | ||
| .reduce(Quad::combine_bounds); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This doesn't do anything since only layers are put into the bounding box. This is always None.
| .reduce(Quad::combine_bounds) | ||
| .reduce(Quad::combine_bounds); | ||
|
|
||
| let root_artwork_bounds = self.document_metadata().bounding_box_document(LayerNodeIdentifier::ROOT_PARENT); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The transform_to_viewport doesn't work for the LayerNodeIdentifier::ROOT_PARENT for legacy reasons. This causes the bounds here to be incorrect.
Graphite/editor/src/messages/portfolio/document/utility_types/document_metadata.rs
Lines 72 to 76 in 1b91198
| pub fn transform_to_viewport(&self, layer: LayerNodeIdentifier) -> DAffine2 { | |
| // We're not allowed to convert the root parent to a node id | |
| if layer == LayerNodeIdentifier::ROOT_PARENT { | |
| return self.document_to_viewport; | |
| } |
Closes #3422
Preview:
cursorful-video-1767970758932.mp4
Since we dont have any layer to export, only an infinite canvas is left though which we can calculate the bounding box.
I tried to create bounding box around extreme drawing points, but still as you can see the final exported image in preview is weird, is it ok ?or what i am thinking is when export mode is all-artwork i can apply 10% (or more) padding to it.