Struct Manager

Source
pub struct Manager {
    pub image: RgbaImage,
    pub color_file: ColorFile,
    pub lookup: HashMap<Rgba<u8>, String>,
}

Fields§

§image: RgbaImage§color_file: ColorFile§lookup: HashMap<Rgba<u8>, String>

Implementations§

Source§

impl Manager

Source

pub fn new(opts: ManagerOptions) -> Manager

Examples found in repository?
examples/biomes/main.rs (line 8)
3fn main() {
4    let opts = manager::ManagerOptions {
5        image_path: String::from("examples/biomes/biomes.png"),
6        color_file_path: String::from("examples/biomes/colors.ron"),
7    };
8    let manager = manager::Manager::new(opts);
9    manager.show_names();
10}
More examples
Hide additional examples
examples/color-names.rs (line 8)
3fn main() {
4    let opts = manager::ManagerOptions {
5        image_path: String::from("examples/biomes/biomes.png"),
6        color_file_path: String::from("examples/biomes/colors.ron"),
7    };
8    let manager = manager::Manager::new(opts);
9    for name in manager.color_names() {
10        println!("{}", name);
11    }
12}
examples/colors.rs (line 8)
3fn main() {
4    let opts = manager::ManagerOptions {
5        image_path: String::from("examples/biomes/biomes.png"),
6        color_file_path: String::from("examples/biomes/colors.ron"),
7    };
8    let manager = manager::Manager::new(opts);
9    for rgb in manager.colors_rgb() {
10        print!("{:?} ", rgb);
11    }
12    for hex in manager.colors_hex() {
13        print!("{:?} ", hex);
14    }
15    println!()
16}
examples/color-extraction.rs (line 8)
3fn main() {
4    let opts = manager::ManagerOptions {
5        image_path: String::from("examples/biomes/biomes.png"),
6        color_file_path: String::from("examples/biomes/colors.ron"),
7    };
8    let manager = manager::Manager::new(opts);
9    for rgb in manager.unique_rgb_colors() {
10        print!("{:?} ", rgb);
11    }
12    for hex in manager.unique_hex_colors() {
13        print!("{} ", hex);
14    }
15    println!()
16}
Source

pub fn get(&self, x: u32, y: u32) -> PixelData

Source

pub fn hash(&self, x: u32, y: u32) -> u64

Source

pub fn colors_hex(&self) -> Vec<String>

Examples found in repository?
examples/colors.rs (line 12)
3fn main() {
4    let opts = manager::ManagerOptions {
5        image_path: String::from("examples/biomes/biomes.png"),
6        color_file_path: String::from("examples/biomes/colors.ron"),
7    };
8    let manager = manager::Manager::new(opts);
9    for rgb in manager.colors_rgb() {
10        print!("{:?} ", rgb);
11    }
12    for hex in manager.colors_hex() {
13        print!("{:?} ", hex);
14    }
15    println!()
16}
Source

pub fn colors_rgb(&self) -> Vec<[u8; 3]>

Examples found in repository?
examples/colors.rs (line 9)
3fn main() {
4    let opts = manager::ManagerOptions {
5        image_path: String::from("examples/biomes/biomes.png"),
6        color_file_path: String::from("examples/biomes/colors.ron"),
7    };
8    let manager = manager::Manager::new(opts);
9    for rgb in manager.colors_rgb() {
10        print!("{:?} ", rgb);
11    }
12    for hex in manager.colors_hex() {
13        print!("{:?} ", hex);
14    }
15    println!()
16}
Source

pub fn color_names(&self) -> Vec<String>

Examples found in repository?
examples/color-names.rs (line 9)
3fn main() {
4    let opts = manager::ManagerOptions {
5        image_path: String::from("examples/biomes/biomes.png"),
6        color_file_path: String::from("examples/biomes/colors.ron"),
7    };
8    let manager = manager::Manager::new(opts);
9    for name in manager.color_names() {
10        println!("{}", name);
11    }
12}
Source

pub fn unique_hex_colors(&self) -> Vec<String>

Examples found in repository?
examples/color-extraction.rs (line 12)
3fn main() {
4    let opts = manager::ManagerOptions {
5        image_path: String::from("examples/biomes/biomes.png"),
6        color_file_path: String::from("examples/biomes/colors.ron"),
7    };
8    let manager = manager::Manager::new(opts);
9    for rgb in manager.unique_rgb_colors() {
10        print!("{:?} ", rgb);
11    }
12    for hex in manager.unique_hex_colors() {
13        print!("{} ", hex);
14    }
15    println!()
16}
Source

pub fn unique_rgb_colors(&self) -> Vec<[u8; 3]>

Examples found in repository?
examples/color-extraction.rs (line 9)
3fn main() {
4    let opts = manager::ManagerOptions {
5        image_path: String::from("examples/biomes/biomes.png"),
6        color_file_path: String::from("examples/biomes/colors.ron"),
7    };
8    let manager = manager::Manager::new(opts);
9    for rgb in manager.unique_rgb_colors() {
10        print!("{:?} ", rgb);
11    }
12    for hex in manager.unique_hex_colors() {
13        print!("{} ", hex);
14    }
15    println!()
16}
Source

pub fn show_names(&self)

Examples found in repository?
examples/biomes/main.rs (line 9)
3fn main() {
4    let opts = manager::ManagerOptions {
5        image_path: String::from("examples/biomes/biomes.png"),
6        color_file_path: String::from("examples/biomes/colors.ron"),
7    };
8    let manager = manager::Manager::new(opts);
9    manager.show_names();
10}

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> 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> SetParameter for T

Source§

fn set<T>(&mut self, value: T) -> <T as Parameter<Self>>::Result
where T: Parameter<Self>,

Sets value as a parameter of self.
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.