[−][src]Struct procedural_generation::Generator
The foundation of this crate
Fields
map: Vec<usize>
width: usize
height: usize
noise_options: NoiseOptions
Implementations
impl Generator
[src]
pub fn new() -> Self
[src]
Create generator.
pub fn with_seed(self, seed: u32) -> Self
[src]
Set seed for noise generation. Useful for reproducing results. Random otherwise.
pub fn with_options(self, options: NoiseOptions) -> Self
[src]
Changes how noise is generated. Different values make for much more interesting noise
pub fn show(&self)
[src]
Prints the map to stdout with colors.
pub fn with_size(self, width: usize, height: usize) -> Self
[src]
Sets size of map. This clears the map as well.
pub fn spawn_perlin<F: Fn(f64) -> usize + Sync>(self, f: F) -> Self
[src]
Generates perlin noise over the entire map.
For every coordinate, the closure f(f64)
receives a value
between 0 and 1. This closure must then return a usize
accordingly to what value it receives, such as the following.
You can also modify some options for how the noise should behave,
see NoiseOptions.
fn main() { Generator::new() .with_size(40, 20) .spawn_perlin(|value| { if value > 0.66 { 2 } else if value > 0.33 { 1 } else { 0 } }) .show(); }
pub fn spawn_rooms(self, number: usize, rooms: usize, size: &Size) -> Self
[src]
Spawns rooms of varying sizes based on input size
. number
sets
what number the rooms are represented with in the map, rooms
is amount of rooms
to generate and size
specifies the minimum and maximum boundaries for each room.
fn main() { let size = Size::new((4, 4), (10, 10)); Generator::new() .with_size(30, 20) .spawn_rooms(2, 3, &size) .show(); }
pub fn get(&self, x: usize, y: usize) -> usize
[src]
Returns value at (x, y) coordinate, useful since map is in 1d form but treated as 2d.
pub fn set(&mut self, x: usize, y: usize, value: usize)
[src]
Same as get(...)
, except sets value.
pub fn get_2d_map(&self) -> Vec<Vec<usize>>
[src]
This is not recommended unless it's convenient or necessary, as 2d vectors are slow.
Trait Implementations
Auto Trait Implementations
impl RefUnwindSafe for Generator
impl Send for Generator
impl Sync for Generator
impl Unpin for Generator
impl UnwindSafe for Generator
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<D> OwoColorize for D
[src]
fn fg<C>(&'a self) -> FgColorDisplay<'a, C, Self> where
C: Color,
[src]
C: Color,
fn bg<C>(&'a self) -> BgColorDisplay<'a, C, Self> where
C: Color,
[src]
C: Color,
fn black(&'a self) -> FgColorDisplay<'a, Black, Self>
[src]
fn on_black(&'a self) -> BgColorDisplay<'a, Black, Self>
[src]
fn red(&'a self) -> FgColorDisplay<'a, Red, Self>
[src]
fn on_red(&'a self) -> BgColorDisplay<'a, Red, Self>
[src]
fn green(&'a self) -> FgColorDisplay<'a, Green, Self>
[src]
fn on_green(&'a self) -> BgColorDisplay<'a, Green, Self>
[src]
fn yellow(&'a self) -> FgColorDisplay<'a, Yellow, Self>
[src]
fn on_yellow(&'a self) -> BgColorDisplay<'a, Yellow, Self>
[src]
fn blue(&'a self) -> FgColorDisplay<'a, Blue, Self>
[src]
fn on_blue(&'a self) -> BgColorDisplay<'a, Blue, Self>
[src]
fn magenta(&'a self) -> FgColorDisplay<'a, Magenta, Self>
[src]
fn on_magenta(&'a self) -> BgColorDisplay<'a, Magenta, Self>
[src]
fn purple(&'a self) -> FgColorDisplay<'a, Magenta, Self>
[src]
fn on_purple(&'a self) -> BgColorDisplay<'a, Magenta, Self>
[src]
fn cyan(&'a self) -> FgColorDisplay<'a, Cyan, Self>
[src]
fn on_cyan(&'a self) -> BgColorDisplay<'a, Cyan, Self>
[src]
fn white(&'a self) -> FgColorDisplay<'a, White, Self>
[src]
fn on_white(&'a self) -> BgColorDisplay<'a, White, Self>
[src]
fn bright_black(&'a self) -> FgColorDisplay<'a, BrightBlack, Self>
[src]
fn on_bright_black(&'a self) -> BgColorDisplay<'a, BrightBlack, Self>
[src]
fn bright_red(&'a self) -> FgColorDisplay<'a, BrightRed, Self>
[src]
fn on_bright_red(&'a self) -> BgColorDisplay<'a, BrightRed, Self>
[src]
fn bright_green(&'a self) -> FgColorDisplay<'a, BrightGreen, Self>
[src]
fn on_bright_green(&'a self) -> BgColorDisplay<'a, BrightGreen, Self>
[src]
fn bright_yellow(&'a self) -> FgColorDisplay<'a, BrightYellow, Self>
[src]
fn on_bright_yellow(&'a self) -> BgColorDisplay<'a, BrightYellow, Self>
[src]
fn bright_blue(&'a self) -> FgColorDisplay<'a, BrightBlue, Self>
[src]
fn on_bright_blue(&'a self) -> BgColorDisplay<'a, BrightBlue, Self>
[src]
fn bright_magenta(&'a self) -> FgColorDisplay<'a, BrightMagenta, Self>
[src]
fn on_bright_magenta(&'a self) -> BgColorDisplay<'a, BrightMagenta, Self>
[src]
fn bright_purple(&'a self) -> FgColorDisplay<'a, BrightMagenta, Self>
[src]
fn on_bright_purple(&'a self) -> BgColorDisplay<'a, BrightMagenta, Self>
[src]
fn bright_cyan(&'a self) -> FgColorDisplay<'a, BrightCyan, Self>
[src]
fn on_bright_cyan(&'a self) -> BgColorDisplay<'a, BrightCyan, Self>
[src]
fn bright_white(&'a self) -> FgColorDisplay<'a, BrightWhite, Self>
[src]
fn on_bright_white(&'a self) -> BgColorDisplay<'a, BrightWhite, Self>
[src]
fn bold(&'a self) -> BoldDisplay<'a, Self>
[src]
fn dimmed(&'a self) -> DimDisplay<'a, Self>
[src]
fn italic(&'a self) -> ItalicDisplay<'a, Self>
[src]
fn underline(&'a self) -> UnderlineDisplay<'a, Self>
[src]
fn blink(&'a self) -> BlinkDisplay<'a, Self>
[src]
fn blink_fast(&'a self) -> BlinkFastDisplay<'a, Self>
[src]
fn reversed(&'a self) -> ReversedDisplay<'a, Self>
[src]
fn hidden(&'a self) -> HiddenDisplay<'a, Self>
[src]
fn strikethrough(&'a self) -> StrikeThroughDisplay<'a, Self>
[src]
fn color<Color>(&'a self, color: Color) -> FgDynColorDisplay<'a, Color, Self> where
Color: DynColor,
[src]
Color: DynColor,
fn on_color<Color>(&'a self, color: Color) -> BgDynColorDisplay<'a, Color, Self> where
Color: DynColor,
[src]
Color: DynColor,
fn truecolor(&'a self, r: u8, g: u8, b: u8) -> FgDynColorDisplay<'a, Rgb, Self>
[src]
fn on_truecolor(
&'a self,
r: u8,
g: u8,
b: u8
) -> BgDynColorDisplay<'a, Rgb, Self>
[src]
&'a self,
r: u8,
g: u8,
b: u8
) -> BgDynColorDisplay<'a, Rgb, Self>
impl<T> ToString for T where
T: Display + ?Sized,
[src]
T: Display + ?Sized,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,