Valora provides a trait, Artist, which you must implement in order to draw. The trait looks like this:
/// A trait for types which paint canvases.pub trait Artist: Sized {/// Constructs the artist.////// This would be a place to compile any GLSL or construct any expensive/// resources needed across the whole composition.fn setup(gpu: Gpu, world: World, rng: &mut StdRng) -> Result<Self>;​/// Paints a single frame.fn paint(&mut self, ctx: Context, canvas: &mut Canvas);}
To run a drawing, call
run::<YourArtistType>(Options::from_args())
Calling Options::from_args()
will provide valora's command line interface, which is shown below. This is all you have to do! The rendering, saving to file, resolutions, seed, etc, can all be configured by the command line interface without any changes to code.
There is also a convenience implementation of Artist
for functions that return painting functions, such as we used in the introduction:
run_fn(Options::from_args(), |gpu, world, rng| {Ok(move |ctx: Context, canvas: &mut Canvas| {// Paint frames here})})
The full command line interface:
Command line options for a painting run.​Construct with `Options::from_args()` to run the CLI.​USAGE:simple [FLAGS] [OPTIONS]​FLAGS:-b, --brainstormIn brainstorm mode:* When rendering a limited number of frames to screen, the previewwill not close.* When rendering to file, every frame will be rendered with adifferent seed.--helpPrints help information​-V, --versionPrints version information​​OPTIONS:-d, --delay <delay>The number of frames to delay saving to file. For example, ifdelay=100, 100 frames will be rendered silently and then the 101stand those after it will be saved to file. [default: 0]-r, --frames_per_second <framerate>The number of frames (to try) to render per second. [default: 24]​-f, --frames <frames>The total number of frames in this painting.​-h, --height <height>The height in coordinate space of the painting.Coordinate space may differ from output space. If height is 500 butscale is 10, the painting will have a coordinate space height of 500,but the final output will have a height of 5000 pixels. [default: 650]-o, --output <output>Prefix of output path. Output is <prefix>/<seed>/<frame_number>.png​-s, --scale <scale>The scale of the output.The final output space is (width*scale)x(height*scale). This value isuseful for painting and doing work at one quickly renderingresolution, and later exporting at a much higher resolution whilepreserving the composition exactly.This value may be needed when writing shaders or using other rastergraphics, to adjust them for the real output size. Vector paintingsuch as with paths should not need to consider this. [default: 1.0]-e, --seed <seed>The RNG seed for this painting. [default: 0]​-w, --width <width>The width in coordinate space of the painting.Coordinate space may differ from output space. If width is 500 butscale is 10, the painting will have a coordinate space width of 500,but the final output will have a width of 5000 pixels. [default: 512]​