Struct libnoise::Visualizer
source · pub struct Visualizer<const D: usize> { /* private fields */ }
Expand description
A struct for visualizing the output of a generator.
The image
feature must be enabled for writing images of visualizations.
This struct represents a simple way to quickly visualize the output of a Generator
by
building a NoiseBuffer
of a given size, populating it with data, and creating an PNG or
GIF file visualizing said data.
In the 1D case, the visualization is a grayscale band of one pixel in height and with the provided length. In the 2D case, the visualization is an image of the provided dimensions. In the 3D case, the visualization is an image providing an isometric view on a cube representing the buffer. In the 4D case, the visualization is equivalent to the 3D case, except the result is an animation with the 4th dimension mapping to time.
Note: This struct is meant to be used to get an idea of what a generator is doing. Especially the 1D, 3D, and 4D cases are not suited for usage besides debugging, as the main goal of this library is to provide an efficient and modular way to creating a noise generation pipeline.
The usage of this struct is simple and analogous to that of NoiseBuffer
:
// create a generator
let generator = Source::simplex(42);
// create a visualizer and use it to visualize the output of the generator
let path = "output.png";
Visualizer::<3>::new([30, 20, 25], &generator).write_to_file(path).unwrap();
In fact, a visualizer can be created from a NoiseBuffer
by simply converting it
to a Visualizer
:
// create a generator
let generator = Source::simplex(42);
// create a noise buffer
let buf = NoiseBuffer::<3>::new([30, 20, 25], &generator);
// create a visualizer and use it to visualize the output of the generator
let path = "output.png";
Visualizer::from(buf).write_to_file(path);
Implementations§
source§impl Visualizer<1>
impl Visualizer<1>
sourcepub fn new<G: Generator<1>>(shape: [usize; 1], generator: &G) -> Self
pub fn new<G: Generator<1>>(shape: [usize; 1], generator: &G) -> Self
Creates a new Visualizer
with the given shape
and filled with noise generated
by the given generator
. For further detail see the
struct-level documentation.
sourcepub fn write_to_file(&self, path: &str) -> Result<(), ImageError>
pub fn write_to_file(&self, path: &str) -> Result<(), ImageError>
Write a PNG file to the given path
, visualizing the output of the provided
generator. For further detail see the struct-level documentation.
source§impl Visualizer<2>
impl Visualizer<2>
sourcepub fn new<G: Generator<2>>(shape: [usize; 2], generator: &G) -> Self
pub fn new<G: Generator<2>>(shape: [usize; 2], generator: &G) -> Self
Creates a new Visualizer
with the given shape
and filled with noise generated
by the given generator
. For further detail see the
struct-level documentation.
pub fn write_to_file(&self, path: &str) -> Result<(), ImageError>
source§impl Visualizer<3>
impl Visualizer<3>
sourcepub fn new<G: Generator<3>>(shape: [usize; 3], generator: &G) -> Self
pub fn new<G: Generator<3>>(shape: [usize; 3], generator: &G) -> Self
Creates a new Visualizer
with the given shape
and filled with noise generated
by the given generator
. For further detail see the
struct-level documentation.
sourcepub fn write_to_file(&self, path: &str) -> Result<(), ImageError>
pub fn write_to_file(&self, path: &str) -> Result<(), ImageError>
Write a PNG file to the given path
, visualizing the output of the provided
generator. For further detail see the struct-level documentation.
source§impl Visualizer<4>
impl Visualizer<4>
sourcepub fn new<G: Generator<4>>(shape: [usize; 4], generator: &G) -> Self
pub fn new<G: Generator<4>>(shape: [usize; 4], generator: &G) -> Self
Creates a new Visualizer
with the given shape
and filled with noise generated
by the given generator
. For further detail see the
struct-level documentation.
sourcepub fn write_to_file(&self, path: &str) -> Result<(), Error>
pub fn write_to_file(&self, path: &str) -> Result<(), Error>
Write a GIF file to the given path
, visualizing the output of the provided
generator. For further detail see the struct-level documentation.
Trait Implementations§
source§impl<const D: usize> Clone for Visualizer<D>
impl<const D: usize> Clone for Visualizer<D>
source§fn clone(&self) -> Visualizer<D>
fn clone(&self) -> Visualizer<D>
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more