Skip to content

`Yew-Canvas.rs` is a simple Canvas component for Yew.

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-Apache
MIT
LICENSE-MIT
Notifications You must be signed in to change notification settings

1216892614/Yew-Canvas.rs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

✨Yew-Canvas.rs✨

中文

Now support Yew 2.20 !

Yew-Canvas.rs is a simple Canvas component for Yew.

U can easily create a canvas with the context u need.

📑How to use it?📑

Just 3 Simple steps, if the context u need is CanvasRenderingContext2d, do like this:

  1. Get Yew-Canvas.rs, HtmlCanvasElement and context type!

    #Cargo.toml
    [dependencies]
    yew="0.19"
    yew-canvas="..."
    
    [dependencies.web-sys]
    version = "0.3.59"
    features = ["HtmlCanvasElement", "CanvasRenderingContext2d"]
  2. Create a Rander struct!

    #[derive(Clone, PartialEq)]
    struct Rander();
    
    impl WithRander for Rander {
        fn rand(self, canvas: &HtmlCanvasElement) {
            
            //...
        }
    }
  3. Return the component as VNode!

    html!(
        <Canvas<CanvasRenderingContext2d, Rander>
            //Just use style, canvas can suit automaticly.
            style="
                width: 100%;
                height: 100%;
            "
            rander={Box::new(Rander())}
        >
            {"The browser is not supported."}
        </Canvas<CanvasRenderingContext2d, Rander>>
    )

👌Run Exmple👌

  1. *This requires you to set up the Yew.rs development environment in advance, the following is a Trunk packaging example:
  2. cd ./examples/base-use
  3. trunk serve

⚖️License⚖️

Yew-Canvas.rs is dual licensed under the MIT license and the Apache License (Version 2.0).

About

`Yew-Canvas.rs` is a simple Canvas component for Yew.

Resources

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-Apache
MIT
LICENSE-MIT

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages