iced-yoda/examples/README.md

78 lines
2.6 KiB
Markdown
Raw Normal View History

2019-09-05 07:18:11 +02:00
# Examples
__Iced moves fast and the `master` branch can contain breaking changes!__ If
you want to learn about a specific release, check out [the release list].
[the release list]: https://github.com/hecrj/iced/releases
2019-10-13 18:51:39 +02:00
## [Tour](tour.rs)
A simple UI tour showcasing different widgets that can be built using Iced.
2019-09-05 07:18:11 +02:00
The example can run both on native and web platforms, using the same GUI code!
2019-10-13 18:51:39 +02:00
[![Tour - Iced][gui_gif]][gui_gfycat]
2019-10-13 18:51:39 +02:00
[gui_gif]: https://thumbs.gfycat.com/VeneratedSourAurochs-small.gif
[gui_gfycat]: https://gfycat.com/veneratedsouraurochs
2019-09-05 07:18:11 +02:00
2019-10-13 18:51:39 +02:00
On native, the example uses:
- [`iced_winit`], as a bridge between [`iced_native`] and [`winit`].
- [`iced_wgpu`], a WIP Iced renderer built on top of [`wgpu`] and supporting
Vulkan, Metal, D3D11, and D3D12 (OpenGL and WebGL soon!).
2019-10-13 18:51:39 +02:00
The web version uses [`iced_web`], which is still a work in progress. In
particular, the styling of elements is not finished yet (text color, alignment,
sizing, etc).
2019-10-13 18:51:39 +02:00
The __[`tour`]__ file contains all the code of the example! All the
cross-platform GUI is defined in terms of __state__, __messages__,
__update logic__ and __view logic__.
2019-10-13 18:51:39 +02:00
[`tour`]: tour.rs
[`iced_winit`]: ../winit
[`iced_native`]: ../native
[`iced_wgpu`]: ../wgpu
[`iced_web`]: ../web
[`winit`]: https://github.com/rust-windowing/winit
[`wgpu`]: https://github.com/gfx-rs/wgpu-rs
2019-10-13 18:51:39 +02:00
#### Running the native version
2019-10-23 02:35:24 +02:00
Use [Cargo](https://doc.rust-lang.org/cargo/reference/manifest.html#examples)
2019-10-13 18:51:39 +02:00
to run the example:
```
2019-10-13 18:51:39 +02:00
cargo run --example tour
```
2019-10-13 18:51:39 +02:00
#### Running the web version
2019-10-23 02:35:24 +02:00
Build using the `wasm32-unknown-unknown` target and use the [`wasm-bindgen`] CLI
to generate appropriate bindings in a `tour` directory.
2019-09-05 07:18:11 +02:00
```
2019-10-23 02:35:24 +02:00
cd examples
cargo build --example tour --target wasm32-unknown-unknown
wasm-bindgen ../target/wasm32-unknown-unknown/debug/examples/tour.wasm --out-dir tour --web
2019-09-05 07:18:11 +02:00
```
2019-10-23 02:47:05 +02:00
Finally, serve the `examples` directory using an HTTP server and access the
2019-10-23 02:35:24 +02:00
`tour.html` file.
[`wasm-bindgen`]: https://github.com/rustwasm/wasm-bindgen
2019-09-05 07:18:11 +02:00
## [Coffee]
Since [Iced was born in May], it has been powering the user interfaces in
[Coffee], an experimental 2D game engine.
If you want to give Iced a try without having to write your own renderer,
2019-09-05 09:37:54 +02:00
the __[`ui` module]__ in [Coffee] is probably your best choice as of now.
2019-09-05 07:18:11 +02:00
[![Tour - Coffee][coffee_gui_gif]][coffee_gui_gfycat]
[Iced was born in May]: https://github.com/hecrj/coffee/pull/35
[`ui` module]: https://docs.rs/coffee/0.3.2/coffee/ui/index.html
[Coffee]: https://github.com/hecrj/coffee
[coffee_gui_gif]: https://thumbs.gfycat.com/GloomyWeakHammerheadshark-small.gif
[coffee_gui_gfycat]: https://gfycat.com/gloomyweakhammerheadshark