Is there a way to render the following Rust turtle drawing in a headless environment?
I'm interested in both exporting the final result to an image file, and the drawing process itself to a video file.
My main.rs
looks like this
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
looks like this
[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
looks like this
FROM rust:latest
WORKDIR /usr/src/doodle
COPY ./src .
CMD cargo run
When running the container I'm getting the following error:
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
Unfortunately, that would have to be something that the developers would need to add in. Looking through the source code, the GUI window is created whenever Turtle::new()
is called, so there isn't a way to start the drawing without needing the window.
It looks like the devs are still working on it though (last commit is less than a month old), so you may try posting an issue on their github mentioning that a feature that allows you to output to a file instead of drawing to the window could be useful.