在无头环境中渲染 Rust turtle
rendering Rust turtle in headless environment
有没有办法在无头环境中渲染以下 Rust turtle 绘图?
我对将最终结果导出到图像文件以及将绘图过程本身导出到视频文件都很感兴趣。
我的main.rs
看起来像这样
use turtle::Turtle;
fn main() {
let mut turtle = Turtle::new();
for _ in 0..360 {
// Move forward three steps
turtle.forward(3.0);
// Rotate to the right (clockwise) by 1 degree
turtle.right(1.0);
}
}
Cargo.toml
看起来像这样
[package]
name = "doodle" # the name of the package
version = "0.1.0" # the current version
edition = "2018"
[dependencies]
turtle = "1.0.0-rc.3"
# Compile turtle and other dependencies with optimizations
[profile.dev.package."*"]
opt-level = 3
Dockerfile
看起来像这样
FROM rust:latest
WORKDIR /usr/src/doodle
COPY ./src .
CMD cargo run
当 运行 容器出现以下错误时:
thread 'main' panicked at 'Failed to initialize any backend! Wayland status: XdgRuntimeDirNotSet X11 status: LibraryOpenError(OpenError { kind: Library, detail: "opening library failed (libXcursor.so.1: cannot open shared object file: No such file or directory); opening library failed (libXcursor.so: cannot open shared object file: No such file or directory)" })', /usr/local/cargo/registry/src/github.com-1ecc6299db9ec823/winit-0.19.5/src/platform/linux/mod.rs:467:9
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
不幸的是,这必须是开发人员需要添加的东西。查看源代码,每当调用 Turtle::new()
时都会创建 GUI window,所以没有'无需 window.
即可开始绘图
看起来开发人员仍在努力(最后一次提交不到一个月),因此您可以尝试在他们的 github 上发布问题,提及允许您输出的功能到文件而不是绘制到 window 可能会有用。
有没有办法在无头环境中渲染以下 Rust turtle 绘图?
我对将最终结果导出到图像文件以及将绘图过程本身导出到视频文件都很感兴趣。
我的main.rs
看起来像这样
use turtle::Turtle;
fn main() {
let mut turtle = Turtle::new();
for _ in 0..360 {
// Move forward three steps
turtle.forward(3.0);
// Rotate to the right (clockwise) by 1 degree
turtle.right(1.0);
}
}
Cargo.toml
看起来像这样
[package]
name = "doodle" # the name of the package
version = "0.1.0" # the current version
edition = "2018"
[dependencies]
turtle = "1.0.0-rc.3"
# Compile turtle and other dependencies with optimizations
[profile.dev.package."*"]
opt-level = 3
Dockerfile
看起来像这样
FROM rust:latest
WORKDIR /usr/src/doodle
COPY ./src .
CMD cargo run
当 运行 容器出现以下错误时:
thread 'main' panicked at 'Failed to initialize any backend! Wayland status: XdgRuntimeDirNotSet X11 status: LibraryOpenError(OpenError { kind: Library, detail: "opening library failed (libXcursor.so.1: cannot open shared object file: No such file or directory); opening library failed (libXcursor.so: cannot open shared object file: No such file or directory)" })', /usr/local/cargo/registry/src/github.com-1ecc6299db9ec823/winit-0.19.5/src/platform/linux/mod.rs:467:9
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
不幸的是,这必须是开发人员需要添加的东西。查看源代码,每当调用 Turtle::new()
时都会创建 GUI window,所以没有'无需 window.
看起来开发人员仍在努力(最后一次提交不到一个月),因此您可以尝试在他们的 github 上发布问题,提及允许您输出的功能到文件而不是绘制到 window 可能会有用。