1
0
mirror of https://github.com/emilk/egui.git synced 2026-06-26 22:53:14 -04:00

Automatically generate screenshots for all examples (#2379)

This commit is contained in:
Emil Ernerfeldt
2022-12-04 17:27:40 +01:00
committed by GitHub
parent b774159fc8
commit 48666e1d7a
60 changed files with 206 additions and 30 deletions

View File

@@ -9,4 +9,6 @@ publish = false
[dependencies]
eframe = { path = "../../crates/eframe" }
eframe = { path = "../../crates/eframe", features = [
"__screenshot", # __screenshot is so we can dump a ascreenshot using EFRAME_SCREENSHOT_TO
] }

View File

@@ -1,3 +1,7 @@
Example how to show a confirm dialog before exiting an application.
```sh
cargo run -p confirm_exit
```
![](screenshot.png)

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.0 KiB

View File

@@ -3,7 +3,10 @@
use eframe::egui;
fn main() {
let options = eframe::NativeOptions::default();
let options = eframe::NativeOptions {
initial_window_size: Some(egui::vec2(320.0, 240.0)),
..Default::default()
};
eframe::run_native(
"Confirm exit",
options,

View File

@@ -9,6 +9,8 @@ publish = false
[dependencies]
eframe = { path = "../../crates/eframe", features = ["glow"] }
eframe = { path = "../../crates/eframe", features = [
"__screenshot", # __screenshot is so we can dump a ascreenshot using EFRAME_SCREENSHOT_TO
] }
egui_glow = { path = "../../crates/egui_glow" }
glow = "0.11"

View File

@@ -13,3 +13,5 @@ If you are content of having egui sit on top of a 3D background, take a look at:
```sh
cargo run -p custom_3d_glow
```
![](screenshot.png)

Binary file not shown.

After

Width:  |  Height:  |  Size: 34 KiB

View File

@@ -11,7 +11,9 @@ publish = false
crate-type = ["cdylib", "rlib"]
[dependencies]
eframe = { path = "../../crates/eframe", features = ["glow"] }
eframe = { path = "../../crates/eframe", features = [
"__screenshot", # __screenshot is so we can dump a ascreenshot using EFRAME_SCREENSHOT_TO
] }
egui_glow = { path = "../../crates/egui_glow" }
glow = "0.11"
three-d = { version = "0.13", default-features = false }

View File

@@ -18,3 +18,5 @@ cargo run -p custom_3d_three-d
```
wasm-pack build examples/custom_3d_three-d --target web
```
![](screenshot.png)

Binary file not shown.

After

Width:  |  Height:  |  Size: 52 KiB

View File

@@ -9,4 +9,6 @@ publish = false
[dependencies]
eframe = { path = "../../crates/eframe" }
eframe = { path = "../../crates/eframe", features = [
"__screenshot", # __screenshot is so we can dump a ascreenshot using EFRAME_SCREENSHOT_TO
] }

View File

@@ -1,3 +1,7 @@
Example of how to use custom fonts.
```sh
cargo run -p custom_font
```
![](screenshot.png)

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.5 KiB

View File

@@ -3,7 +3,10 @@
use eframe::egui;
fn main() {
let options = eframe::NativeOptions::default();
let options = eframe::NativeOptions {
initial_window_size: Some(egui::vec2(320.0, 240.0)),
..Default::default()
};
eframe::run_native(
"egui example: custom font",
options,

View File

@@ -9,4 +9,6 @@ publish = false
[dependencies]
eframe = { path = "../../crates/eframe" }
eframe = { path = "../../crates/eframe", features = [
"__screenshot", # __screenshot is so we can dump a ascreenshot using EFRAME_SCREENSHOT_TO
] }

View File

@@ -1,4 +1,7 @@
Example how to define custom test styles.
```sh
cargo run -p custom_font_style
```
![custom_font_style example](custom_font_style.png)
![](screenshot.png)

Binary file not shown.

Before

Width:  |  Height:  |  Size: 75 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 59 KiB

View File

@@ -9,4 +9,6 @@ publish = false
[dependencies]
eframe = { path = "../../crates/eframe" }
eframe = { path = "../../crates/eframe", features = [
"__screenshot", # __screenshot is so we can dump a ascreenshot using EFRAME_SCREENSHOT_TO
] }

View File

@@ -1,3 +1,7 @@
Example how to show a custom window frame instead of the default OS window chrome decorations.
```sh
cargo run -p custom_window_frame
```
![](screenshot.png)

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.2 KiB

View File

@@ -11,6 +11,7 @@ fn main() {
// To have rounded corners we need transparency:
transparent: true,
min_window_size: Some(egui::vec2(320.0, 100.0)),
initial_window_size: Some(egui::vec2(320.0, 240.0)),
..Default::default()
};
eframe::run_native(

View File

@@ -9,7 +9,9 @@ publish = false
[dependencies]
eframe = { path = "../../crates/eframe" }
eframe = { path = "../../crates/eframe", features = [
"__screenshot", # __screenshot is so we can dump a ascreenshot using EFRAME_SCREENSHOT_TO
] }
egui_extras = { path = "../../crates/egui_extras", features = ["image"] }
ehttp = "0.2"
image = { version = "0.24", default-features = false, features = ["jpeg"] }

View File

@@ -1,3 +1,7 @@
Example how to download and show an image with eframe/egui.
```sh
cargo run -p download_image
```
![](screenshot.png)

Binary file not shown.

After

Width:  |  Height:  |  Size: 353 KiB

View File

@@ -9,5 +9,7 @@ publish = false
[dependencies]
eframe = { path = "../../crates/eframe" }
eframe = { path = "../../crates/eframe", features = [
"__screenshot", # __screenshot is so we can dump a ascreenshot using EFRAME_SCREENSHOT_TO
] }
rfd = "0.10"

View File

@@ -3,3 +3,5 @@ How to show a file dialog using [`rfd`](https://github.com/PolyMeilex/rfd).
```sh
cargo run -p file_dialog
```
![](screenshot.png)

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.8 KiB

View File

@@ -5,6 +5,7 @@ use eframe::egui;
fn main() {
let options = eframe::NativeOptions {
drag_and_drop_support: true,
initial_window_size: Some(egui::vec2(320.0, 240.0)),
..Default::default()
};
eframe::run_native(

View File

@@ -9,5 +9,7 @@ publish = false
[dependencies]
eframe = { path = "../../crates/eframe" }
eframe = { path = "../../crates/eframe", features = [
"__screenshot", # __screenshot is so we can dump a ascreenshot using EFRAME_SCREENSHOT_TO
] }
tracing-subscriber = "0.3"

View File

@@ -1,3 +1,7 @@
Example showing some UI controls like `Label`, `TextEdit`, `Slider`, `Button`.
```sh
cargo run -p hello_world
```
![](screenshot.png)

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.5 KiB

View File

@@ -6,7 +6,10 @@ fn main() {
// Log to stdout (if you run with `RUST_LOG=debug`).
tracing_subscriber::fmt::init();
let options = eframe::NativeOptions::default();
let options = eframe::NativeOptions {
initial_window_size: Some(egui::vec2(320.0, 240.0)),
..Default::default()
};
eframe::run_native(
"My egui App",
options,

View File

@@ -9,5 +9,7 @@ publish = false
[dependencies]
eframe = { path = "../../crates/eframe" }
eframe = { path = "../../crates/eframe", features = [
"__screenshot", # __screenshot is so we can dump a ascreenshot using EFRAME_SCREENSHOT_TO
] }
tracing-subscriber = "0.3"

View File

@@ -1,3 +1,5 @@
```sh
cargo run -p hello_world
```
![](screenshot.png)

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.3 KiB

View File

@@ -9,6 +9,8 @@ publish = false
[dependencies]
eframe = { path = "../../crates/eframe", features = ["puffin"] }
eframe = { path = "../../crates/eframe", features = [
"__screenshot", # __screenshot is so we can dump a ascreenshot using EFRAME_SCREENSHOT_TO
] }
puffin = "0.14"
puffin_http = "0.11"

View File

@@ -7,3 +7,5 @@ cargo run -p puffin_profiler &
cargo install puffin_viewer
puffin_viewer --url 127.0.0.1:8585
```
![](screenshot.png)

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

View File

@@ -9,6 +9,8 @@ publish = false
[dependencies]
eframe = { path = "../../crates/eframe" }
eframe = { path = "../../crates/eframe", features = [
"__screenshot", # __screenshot is so we can dump a ascreenshot using EFRAME_SCREENSHOT_TO
] }
egui_extras = { path = "../../crates/egui_extras", features = ["image"] }
image = { version = "0.24", default-features = false, features = ["png"] }

View File

@@ -1,3 +1,7 @@
Example how to show an image with eframe/egui.
```sh
cargo run -p retained_image
```
![](screenshot.png)

Binary file not shown.

After

Width:  |  Height:  |  Size: 148 KiB

View File

@@ -5,7 +5,7 @@ use egui_extras::RetainedImage;
fn main() {
let options = eframe::NativeOptions {
initial_window_size: Some(egui::vec2(500.0, 900.0)),
initial_window_size: Some(egui::vec2(300.0, 900.0)),
..Default::default()
};

View File

@@ -9,6 +9,8 @@ publish = false
[dependencies]
eframe = { path = "../../crates/eframe" }
eframe = { path = "../../crates/eframe", features = [
"__screenshot", # __screenshot is so we can dump a ascreenshot using EFRAME_SCREENSHOT_TO
] }
egui_extras = { path = "../../crates/egui_extras", features = ["image"] }
itertools = "0.10.3"

View File

@@ -1,3 +1,7 @@
Example how to take screenshots and display them with eframe/egui.
```sh
cargo run -p screenshot
```
![](screenshot.png)

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.5 KiB

View File

@@ -74,23 +74,25 @@ impl eframe::App for MyApp {
self.take_screenshot = false;
if let Some(gl) = frame.gl() {
let mut buf = vec![0u8; screen_size_px[0] as usize * screen_size_px[1] as usize * 4];
let [w, h] = screen_size_px;
let mut buf = vec![0u8; w as usize * h as usize * 4];
let pixels = glow::PixelPackData::Slice(&mut buf[..]);
unsafe {
gl.read_pixels(
0,
0,
screen_size_px[0] as i32,
screen_size_px[1] as i32,
w as i32,
h as i32,
glow::RGBA,
glow::UNSIGNED_BYTE,
pixels,
);
}
// Flip vertically:
let mut rows: Vec<Vec<u8>> = buf
.into_iter()
.chunks(screen_size_px[0] as usize * 4)
.chunks(w as usize * 4)
.into_iter()
.map(|chunk| chunk.collect())
.collect();

View File

@@ -9,4 +9,6 @@ publish = false
[dependencies]
eframe = { path = "../../crates/eframe" }
eframe = { path = "../../crates/eframe", features = [
"__screenshot", # __screenshot is so we can dump a ascreenshot using EFRAME_SCREENSHOT_TO
] }

View File

@@ -6,3 +6,5 @@ See also <https://github.com/emilk/egui/issues/1918>.
```sh
cargo run -p serial_windows
```
![](screenshot.png)

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

View File

@@ -9,6 +9,7 @@ fn main() {
let options = eframe::NativeOptions {
run_and_return: true,
initial_window_size: Some(egui::vec2(320.0, 240.0)),
..Default::default()
};

View File

@@ -9,5 +9,7 @@ publish = false
[dependencies]
eframe = { path = "../../crates/eframe" }
eframe = { path = "../../crates/eframe", features = [
"__screenshot", # __screenshot is so we can dump a ascreenshot using EFRAME_SCREENSHOT_TO
] }
egui_extras = { path = "../../crates/egui_extras", features = ["svg"] }

View File

@@ -1,6 +1,7 @@
Example how to show an SVG image.
```sh
cargo run -p svg
```
![](screenshot.png)

BIN
examples/svg/screenshot.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 59 KiB