-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
add svg basics test and example #751
add svg basics test and example #751
Conversation
Looks like there's a bunch of compilation errors: https://travis-ci.org/rustwasm/wasm-bindgen/jobs/420500433#L3876 Does this compile and run OK for you locally? |
d47f71c
to
6e7e82f
Compare
In fact locally my example doesn't build but neither the old one (dom, hello-word...etc)
|
In the end of the build, I get this errors: |
Have you tried a |
6e7e82f
to
f886559
Compare
Thanks @fitzgen |
examples/svg/src/lib.rs
Outdated
// signatures documented on MDN, for example | ||
#[wasm_bindgen] | ||
extern "C" { | ||
type HTMLDocument; |
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.
All of this should instead be using web-sys
; the goal is to show off an example of working with SVG using web-sys
.
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.
Yes i understand that, but even in raw javascript we don't use any svg class to create and append svg in the dom.
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.
Sorry I wasn't clear: it should be using web_sys::HtmlDocument
isntead of a custom import, and web_sys::HtmlDocument::create_element_ns
etc..
examples/svg/.gitignore
Outdated
package-lock.json | ||
dom.js | ||
dom_bg.js | ||
dom_bg.wasm |
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.
"dom" -> "svg" for all these
examples/svg/src/lib.rs
Outdated
let path = document.createElementNS("http://www.w3.org/2000/svg", "path"); | ||
path.set_attribute("d", &JsValue::from("M100,0 L200,100 100,200 0,100Z")); | ||
path.set_attribute("fill", &JsValue::from("red")); | ||
svg.append_child(&path); |
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.
I think we want something that is slightly more compelling than a red diamond (I think that's what this is?)
How about porting
<svg width="100%" height="100%">
<rect width="100%" height="100%" fill="red" />
<circle cx="100%" cy="100%" r="150" fill="blue" stroke="black" />
<polygon points="120,0 240,225 0,225" fill="green"/>
<text x="50" y="100" font-family="Verdana" font-size="55"
fill="white" stroke="black" stroke-width="2">
Hello!
</text>
</svg>
from https://developer.mozilla.org/en-US/docs/Learn/HTML/Multimedia_and_embedding/Adding_vector_graphics_to_the_Web to web-sys
?
f886559
to
902d367
Compare
902d367
to
87a7e78
Compare
What's the status for this? |
I'm gonna close this as it's been a bit quiet and stale for some time now, but we can of course resubmit at any time! |
#448