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

xilem_web: Setting fill color on SVG stroke fails to compile #446

Closed
armansito opened this issue Jul 24, 2024 · 4 comments · Fixed by #447
Closed

xilem_web: Setting fill color on SVG stroke fails to compile #446

armansito opened this issue Jul 24, 2024 · 4 comments · Fixed by #447

Comments

@armansito
Copy link

I have the following code snippet:

path.stroke(Color::BLACK, stroke_thin.clone()).fill(Color::TRANSPARENT)

Where path is a kurbo::BezPath. This fails to compile with the following message:

error[E0599]: the method `fill` exists for struct `Stroke<BezPath, _, _>`, but its trait bounds were not satisfied
   --> src/lib.rs:135:56
    |
135 |         path.stroke(Color::BLACK, stroke_thin.clone()).fill(Color::TRANSPARENT),
    |                                                        ^^^^ method cannot be called on `Stroke<BezPath, _, _>` due to unsatisfied trait bounds
    |
    = note: the following trait bounds were not satisfied:
            `&xilem_web::svg::Stroke<BezPath, _, _>: xilem_web::interfaces::SvgGeometryElement<_, _>`
            which is required by `&xilem_web::svg::Stroke<BezPath, _, _>: xilem_web::interfaces::SvgCircleElement<_, _>`
            `<&xilem_web::svg::Stroke<BezPath, _, _> as View<_, _, ViewCtx, Box<(dyn xilem_web::Message + 'static)>>>::Element = Pod<_, _>`
            which is required by `&xilem_web::svg::Stroke<BezPath, _, _>: xilem_web::interfaces::SvgCircleElement<_, _>`
            `&xilem_web::svg::Stroke<BezPath, _, _>: View<_, _, ViewCtx, Box<(dyn xilem_web::Message + 'static)>>`
            which is required by `&xilem_web::svg::Stroke<BezPath, _, _>: xilem_web::interfaces::SvgCircleElement<_, _>`
            `&xilem_web::svg::Stroke<BezPath, _, _>: xilem_web::interfaces::SvgGeometryElement<_, _>`
            which is required by `&xilem_web::svg::Stroke<BezPath, _, _>: xilem_web::interfaces::SvgEllipseElement<_, _>`
            `<&xilem_web::svg::Stroke<BezPath, _, _> as View<_, _, ViewCtx, Box<(dyn xilem_web::Message + 'static)>>>::Element = Pod<_, _>`
            which is required by `&xilem_web::svg::Stroke<BezPath, _, _>: xilem_web::interfaces::SvgEllipseElement<_, _>`
            `&xilem_web::svg::Stroke<BezPath, _, _>: View<_, _, ViewCtx, Box<(dyn xilem_web::Message + 'static)>>`
            which is required by `&xilem_web::svg::Stroke<BezPath, _, _>: xilem_web::interfaces::SvgEllipseElement<_, _>`
            `&xilem_web::svg::Stroke<BezPath, _, _>: SvgGraphicsElement<_, _>`
            which is required by `&xilem_web::svg::Stroke<BezPath, _, _>: xilem_web::interfaces::SvggElement<_, _>`
            `<&xilem_web::svg::Stroke<BezPath, _, _> as View<_, _, ViewCtx, Box<(dyn xilem_web::Message + 'static)>>>::Element = Pod<_, _>`
            which is required by `&xilem_web::svg::Stroke<BezPath, _, _>: xilem_web::interfaces::SvggElement<_, _>`
            `&xilem_web::svg::Stroke<BezPath, _, _>: View<_, _, ViewCtx, Box<(dyn xilem_web::Message + 'static)>>`
            which is required by `&xilem_web::svg::Stroke<BezPath, _, _>: xilem_web::interfaces::SvggElement<_, _>`
            `&xilem_web::svg::Stroke<BezPath, _, _>: SvgElement<_, _>`
            which is required by `&xilem_web::svg::Stroke<BezPath, _, _>: xilem_web::interfaces::SvgmPathElement<_, _>`
            `<&xilem_web::svg::Stroke<BezPath, _, _> as View<_, _, ViewCtx, Box<(dyn xilem_web::Message + 'static)>>>::Element = Pod<_, _>`
            which is required by `&xilem_web::svg::Stroke<BezPath, _, _>: xilem_web::interfaces::SvgmPathElement<_, _>`
            `&xilem_web::svg::Stroke<BezPath, _, _>: View<_, _, ViewCtx, Box<(dyn xilem_web::Message + 'static)>>`
            which is required by `&xilem_web::svg::Stroke<BezPath, _, _>: xilem_web::interfaces::SvgmPathElement<_, _>`
            `&xilem_web::svg::Stroke<BezPath, _, _>: xilem_web::interfaces::SvgGeometryElement<_, _>`
            which is required by `&xilem_web::svg::Stroke<BezPath, _, _>: xilem_web::interfaces::SvgPolygonElement<_, _>`
            `<&xilem_web::svg::Stroke<BezPath, _, _> as View<_, _, ViewCtx, Box<(dyn xilem_web::Message + 'static)>>>::Element = Pod<_, _>`
            which is required by `&xilem_web::svg::Stroke<BezPath, _, _>: xilem_web::interfaces::SvgPolygonElement<_, _>`
            `&xilem_web::svg::Stroke<BezPath, _, _>: View<_, _, ViewCtx, Box<(dyn xilem_web::Message + 'static)>>`
            which is required by `&xilem_web::svg::Stroke<BezPath, _, _>: xilem_web::interfaces::SvgPolygonElement<_, _>`
            `&xilem_web::svg::Stroke<BezPath, _, _>: xilem_web::interfaces::SvgGeometryElement<_, _>`
            which is required by `&xilem_web::svg::Stroke<BezPath, _, _>: xilem_web::interfaces::SvgPolylineElement<_, _>`
            `<&xilem_web::svg::Stroke<BezPath, _, _> as View<_, _, ViewCtx, Box<(dyn xilem_web::Message + 'static)>>>::Element = Pod<_, _>`
            which is required by `&xilem_web::svg::Stroke<BezPath, _, _>: xilem_web::interfaces::SvgPolylineElement<_, _>`
            `&xilem_web::svg::Stroke<BezPath, _, _>: View<_, _, ViewCtx, Box<(dyn xilem_web::Message + 'static)>>`
            which is required by `&xilem_web::svg::Stroke<BezPath, _, _>: xilem_web::interfaces::SvgPolylineElement<_, _>`
            `&xilem_web::svg::Stroke<BezPath, _, _>: xilem_web::interfaces::SvgGeometryElement<_, _>`
            which is required by `&xilem_web::svg::Stroke<BezPath, _, _>: xilem_web::interfaces::SvgRectElement<_, _>`
            `<&xilem_web::svg::Stroke<BezPath, _, _> as View<_, _, ViewCtx, Box<(dyn xilem_web::Message + 'static)>>>::Element = Pod<_, _>`
            which is required by `&xilem_web::svg::Stroke<BezPath, _, _>: xilem_web::interfaces::SvgRectElement<_, _>`
            `&xilem_web::svg::Stroke<BezPath, _, _>: View<_, _, ViewCtx, Box<(dyn xilem_web::Message + 'static)>>`
            which is required by `&xilem_web::svg::Stroke<BezPath, _, _>: xilem_web::interfaces::SvgRectElement<_, _>`
            `&xilem_web::svg::Stroke<BezPath, _, _>: SvgGraphicsElement<_, _>`
            which is required by `&xilem_web::svg::Stroke<BezPath, _, _>: xilem_web::interfaces::SvgTextContentElement<_, _>`
            `<&xilem_web::svg::Stroke<BezPath, _, _> as View<_, _, ViewCtx, Box<(dyn xilem_web::Message + 'static)>>>::Element = Pod<_, _>`
            which is required by `&xilem_web::svg::Stroke<BezPath, _, _>: xilem_web::interfaces::SvgTextContentElement<_, _>`
            `&xilem_web::svg::Stroke<BezPath, _, _>: View<_, _, ViewCtx, Box<(dyn xilem_web::Message + 'static)>>`
            which is required by `&xilem_web::svg::Stroke<BezPath, _, _>: xilem_web::interfaces::SvgTextContentElement<_, _>`
            `&mut xilem_web::svg::Stroke<BezPath, _, _>: xilem_web::interfaces::SvgGeometryElement<_, _>`
            which is required by `&mut xilem_web::svg::Stroke<BezPath, _, _>: xilem_web::interfaces::SvgCircleElement<_, _>`
            `<&mut xilem_web::svg::Stroke<BezPath, _, _> as View<_, _, ViewCtx, Box<(dyn xilem_web::Message + 'static)>>>::Element = Pod<_, _>`
            which is required by `&mut xilem_web::svg::Stroke<BezPath, _, _>: xilem_web::interfaces::SvgCircleElement<_, _>`
            `&mut xilem_web::svg::Stroke<BezPath, _, _>: View<_, _, ViewCtx, Box<(dyn xilem_web::Message + 'static)>>`
            which is required by `&mut xilem_web::svg::Stroke<BezPath, _, _>: xilem_web::interfaces::SvgCircleElement<_, _>`
            `&mut xilem_web::svg::Stroke<BezPath, _, _>: xilem_web::interfaces::SvgGeometryElement<_, _>`
            which is required by `&mut xilem_web::svg::Stroke<BezPath, _, _>: xilem_web::interfaces::SvgEllipseElement<_, _>`
            `<&mut xilem_web::svg::Stroke<BezPath, _, _> as View<_, _, ViewCtx, Box<(dyn xilem_web::Message + 'static)>>>::Element = Pod<_, _>`
            which is required by `&mut xilem_web::svg::Stroke<BezPath, _, _>: xilem_web::interfaces::SvgEllipseElement<_, _>`
            `&mut xilem_web::svg::Stroke<BezPath, _, _>: View<_, _, ViewCtx, Box<(dyn xilem_web::Message + 'static)>>`
            which is required by `&mut xilem_web::svg::Stroke<BezPath, _, _>: xilem_web::interfaces::SvgEllipseElement<_, _>`
            `&mut xilem_web::svg::Stroke<BezPath, _, _>: SvgGraphicsElement<_, _>`
            which is required by `&mut xilem_web::svg::Stroke<BezPath, _, _>: xilem_web::interfaces::SvggElement<_, _>`
            `<&mut xilem_web::svg::Stroke<BezPath, _, _> as View<_, _, ViewCtx, Box<(dyn xilem_web::Message + 'static)>>>::Element = Pod<_, _>`
            which is required by `&mut xilem_web::svg::Stroke<BezPath, _, _>: xilem_web::interfaces::SvggElement<_, _>`
            `&mut xilem_web::svg::Stroke<BezPath, _, _>: View<_, _, ViewCtx, Box<(dyn xilem_web::Message + 'static)>>`
            which is required by `&mut xilem_web::svg::Stroke<BezPath, _, _>: xilem_web::interfaces::SvggElement<_, _>`
            `&mut xilem_web::svg::Stroke<BezPath, _, _>: SvgElement<_, _>`
            which is required by `&mut xilem_web::svg::Stroke<BezPath, _, _>: xilem_web::interfaces::SvgmPathElement<_, _>`
            `<&mut xilem_web::svg::Stroke<BezPath, _, _> as View<_, _, ViewCtx, Box<(dyn xilem_web::Message + 'static)>>>::Element = Pod<_, _>`
            which is required by `&mut xilem_web::svg::Stroke<BezPath, _, _>: xilem_web::interfaces::SvgmPathElement<_, _>`
            `&mut xilem_web::svg::Stroke<BezPath, _, _>: View<_, _, ViewCtx, Box<(dyn xilem_web::Message + 'static)>>`
            which is required by `&mut xilem_web::svg::Stroke<BezPath, _, _>: xilem_web::interfaces::SvgmPathElement<_, _>`
            `&mut xilem_web::svg::Stroke<BezPath, _, _>: xilem_web::interfaces::SvgGeometryElement<_, _>`
            which is required by `&mut xilem_web::svg::Stroke<BezPath, _, _>: xilem_web::interfaces::SvgPolygonElement<_, _>`
            `<&mut xilem_web::svg::Stroke<BezPath, _, _> as View<_, _, ViewCtx, Box<(dyn xilem_web::Message + 'static)>>>::Element = Pod<_, _>`
            which is required by `&mut xilem_web::svg::Stroke<BezPath, _, _>: xilem_web::interfaces::SvgPolygonElement<_, _>`
            `&mut xilem_web::svg::Stroke<BezPath, _, _>: View<_, _, ViewCtx, Box<(dyn xilem_web::Message + 'static)>>`
            which is required by `&mut xilem_web::svg::Stroke<BezPath, _, _>: xilem_web::interfaces::SvgPolygonElement<_, _>`
            `&mut xilem_web::svg::Stroke<BezPath, _, _>: xilem_web::interfaces::SvgGeometryElement<_, _>`
            which is required by `&mut xilem_web::svg::Stroke<BezPath, _, _>: xilem_web::interfaces::SvgPolylineElement<_, _>`
            `<&mut xilem_web::svg::Stroke<BezPath, _, _> as View<_, _, ViewCtx, Box<(dyn xilem_web::Message + 'static)>>>::Element = Pod<_, _>`
            which is required by `&mut xilem_web::svg::Stroke<BezPath, _, _>: xilem_web::interfaces::SvgPolylineElement<_, _>`
            `&mut xilem_web::svg::Stroke<BezPath, _, _>: View<_, _, ViewCtx, Box<(dyn xilem_web::Message + 'static)>>`
            which is required by `&mut xilem_web::svg::Stroke<BezPath, _, _>: xilem_web::interfaces::SvgPolylineElement<_, _>`
            `&mut xilem_web::svg::Stroke<BezPath, _, _>: xilem_web::interfaces::SvgGeometryElement<_, _>`
            which is required by `&mut xilem_web::svg::Stroke<BezPath, _, _>: xilem_web::interfaces::SvgRectElement<_, _>`
            `<&mut xilem_web::svg::Stroke<BezPath, _, _> as View<_, _, ViewCtx, Box<(dyn xilem_web::Message + 'static)>>>::Element = Pod<_, _>`
            which is required by `&mut xilem_web::svg::Stroke<BezPath, _, _>: xilem_web::interfaces::SvgRectElement<_, _>`
            `&mut xilem_web::svg::Stroke<BezPath, _, _>: View<_, _, ViewCtx, Box<(dyn xilem_web::Message + 'static)>>`
            which is required by `&mut xilem_web::svg::Stroke<BezPath, _, _>: xilem_web::interfaces::SvgRectElement<_, _>`
            `&mut xilem_web::svg::Stroke<BezPath, _, _>: SvgGraphicsElement<_, _>`
            which is required by `&mut xilem_web::svg::Stroke<BezPath, _, _>: xilem_web::interfaces::SvgTextContentElement<_, _>`
            `<&mut xilem_web::svg::Stroke<BezPath, _, _> as View<_, _, ViewCtx, Box<(dyn xilem_web::Message + 'static)>>>::Element = Pod<_, _>`
            which is required by `&mut xilem_web::svg::Stroke<BezPath, _, _>: xilem_web::interfaces::SvgTextContentElement<_, _>`
            `&mut xilem_web::svg::Stroke<BezPath, _, _>: View<_, _, ViewCtx, Box<(dyn xilem_web::Message + 'static)>>`
            which is required by `&mut xilem_web::svg::Stroke<BezPath, _, _>: xilem_web::interfaces::SvgTextContentElement<_, _>`

The error message isn't very helpful. This code used to work on an earlier version of xilem_web but I'm not entirely sure when this broke. For more details on surrounding context, see linebender/gpu-stroke-expansion-paper#46

@Philipp-M
Copy link
Contributor

Hmm the error message is aweful, I hope we can improve that somehow. Can you check, if #447 fixes the issue? I'm pretty sure it broke with #403 and I wasn't thorough enough

@Philipp-M
Copy link
Contributor

I'v checked it in the linked paper demo, where it works now for me, nice demo btw.

github-merge-queue bot pushed a commit that referenced this issue Jul 24, 2024
…ement` (#447)

Fixes #446 

I guess I missed the m before the path
@armansito
Copy link
Author

Thanks! I verified that #447 fixes the issue.

@Philipp-M
Copy link
Contributor

FWIW, I've opened an issue in rust-lang/rust#128540 regarding that error message.

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 a pull request may close this issue.

2 participants