Skip to main content

BiomeColorMap

Struct BiomeColorMap 

Source
pub struct BiomeColorMap(/* private fields */);
Expand description

A map of biomeids to colors

This function is useful for generating pictures of biome maps.

The colors are mapped as an array, the elements corresponding to the Red Green And blue value respectively. eg [RED, GREEN, BLUE] The map should contain all biomes available in minecraft.

The color scheme comes from cubiomes. The color scheme in cubiomes is strongly inspired by the color scheme used in AMIDST

It’s implemented as its own type which uses an array as its backend. The array maps each biomeid number to a color. The id’s which dont map to a id are 0.

§Usage

The map is meant to use by indexing

§Examples

// Modify a specific biomes color from the default
use cubiomes::{enums::BiomeID, colors::BiomeColorMap};

let mut color_map = BiomeColorMap::default();
let new_color = [0, 120, 255];

color_map[BiomeID::badlands] = new_color;

assert_eq!(color_map[BiomeID::badlands], new_color);

§Details

The arraymap approach was benchmarked to be faster than a map type. If you still desire a seperate map type you can use new_biome_color_map() instead.

Implementations§

Source§

impl BiomeColorMap

Source

pub fn new() -> Self

Constructs a new BiomeColorMap with colors from cubiomes.

Source

pub fn get(&self, idx: BiomeID) -> &[u8; 3]

Gets a specific BiomeID’s color from the map. If not found (for some reason) returns None. The map should contain all biomes.

Source

pub fn get_mut(&mut self, idx: BiomeID) -> &mut [u8; 3]

Gets a mutable reference to a specific BiomeID’s color.

The function can be used to mutate the color map

Source

pub fn as_arr(&self) -> &[[u8; 3]; 256]

Returns a reference to the underlying array of the map.

Source

pub fn to_arr(&self) -> [[u8; 3]; 256]

Returns a copy of the underlying array in the map.

Trait Implementations§

Source§

impl Clone for BiomeColorMap

Source§

fn clone(&self) -> BiomeColorMap

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for BiomeColorMap

Source§

impl Debug for BiomeColorMap

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for BiomeColorMap

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl Index<BiomeID> for BiomeColorMap

Source§

type Output = [u8; 3]

The returned type after indexing.
Source§

fn index(&self, index: BiomeID) -> &Self::Output

Performs the indexing (container[index]) operation. Read more
Source§

impl IndexMut<BiomeID> for BiomeColorMap

Source§

fn index_mut(&mut self, index: BiomeID) -> &mut Self::Output

Performs the mutable indexing (container[index]) operation. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.