Skip to content
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

feat: update vello_svg to usvg 0.37, fix some artifacts. #422

Merged
merged 7 commits into from
Feb 13, 2024

Conversation

simbleau
Copy link
Member

@simbleau simbleau commented Jan 19, 2024

  • Ignores DS_Store
  • Updates to usvg 0.37
  • Update the docs on integrations

Copy link
Member

@DJMcNab DJMcNab left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've not run this yet, but some initial thoughts on the code/changes

This looks useful, thanks!

gr.transform.e,
gr.transform.f,
]);
let start: vello::kurbo::Point = (gr.x1 as f64, gr.y1 as f64).into();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I'd use Point::new or Point::from here

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, I see you're copying the extant style

In that case, I guess either is fine

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I also think it should be a common convention across the file. I'll try to make it consistent when I get to my next revision.

integrations/vello_svg/src/lib.rs Show resolved Hide resolved
/// Append a [`usvg::Tree`] into a Vello [`SceneBuilder`], with default error handling
/// This will draw a red box over (some) unsupported elements
/// Append a [`usvg::Tree`] into a Vello [`SceneBuilder`], with default error
/// handling This will draw a red box over (some) unsupported elements
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is an odd change.

I must have failed to put two spaces after handling, previously. I'd propose at least putting a full stop between the two

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will be fixed. It was a bad auto-format.

tx,
ty,
} = elt.abs_transform();
let (a, b, c, d, e, f) = (
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd be tempted to make a single array, then map it through f64::from and pass that straight to the constructor

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, what? Like this?

let x: [f64; 6] = [sx, ky, ...].into();

Copy link
Member

@DJMcNab DJMcNab Jan 25, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, so:

let arr = [...].map(f64::from);
let transform = Affine::new(arr);

(Where ... is the components in the right order)

render_tree_with(sb, svg, default_error_handler).unwrap_or_else(|e| match e {});
/// See the [module level documentation](crate#unsupported-features) for a list
/// of some unsupported svg features
pub fn render_tree(sb: &mut SceneBuilder, svg: &usvg::Tree, transform: Option<Affine>) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this transform needed? You can append a fragment created using this to a scene with an applied transform

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm, I think once upon a time I needed this to pass an Affine, like this:

image

However, it seems like I don't need this anymore, you're right! I'll get this fixed.

};

/// Re-export vello.
pub use vello;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, I'm less sure if we should do this, although I can't put my finger on why

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is reasonable - vello-svg is a separate crate the way it's currently laid out. It seems weird to expose usvg but not vello.

If your only intention is to render a list of SVG images and save them with vello-svg, you're out of luck, since there is no re-export of vello. You would need to ensure you also pull in vello, which means maintaining more dependency versions which can get mismatched.

integrations/vello_svg/src/lib.rs Show resolved Hide resolved
README.md Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
.gitignore Show resolved Hide resolved
@DJMcNab
Copy link
Member

DJMcNab commented Feb 8, 2024

@simbleau just want to check on the status of this - I think we're waiting on your changes

@simbleau
Copy link
Member Author

simbleau commented Feb 8, 2024

@simbleau just want to check on the status of this - I think we're waiting on your changes

Acknowledged. Will try to prioritize this today or tomorrow.

@simbleau
Copy link
Member Author

simbleau commented Feb 8, 2024

@DJMcNab Ready to go.

Copy link
Member

@DJMcNab DJMcNab left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! This works as expected locally and on Android

@simbleau simbleau merged commit b8f09b6 into linebender:main Feb 13, 2024
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants