[][src]Struct density_mesh_core::DensityMap

pub struct DensityMap { /* fields omitted */ }

Density map that contains density data and steepness per pixel.

Implementations

impl DensityMap[src]

pub fn new(
    width: usize,
    height: usize,
    scale: usize,
    data: Vec<u8>
) -> Result<Self, DensityMapError>
[src]

Create new density map.

Arguments

  • width - Columns.
  • height - Rows.
  • scale - Scale.
  • data - Raw pixel data.

Returns

Density map or error.

Examples

use density_mesh_core::*;

assert!(DensityMap::new(2, 2, 1, vec![0, 1, 2, 3]).is_ok());
assert_eq!(
    DensityMap::new(1, 2, 1, vec![0, 1, 2, 3]),
    Err(DensityMapError::WrongDataLength(4, 2)),
);

pub fn scale(&self) -> usize[src]

Returns scale.

pub fn width(&self) -> usize[src]

Returns scaled width.

pub fn height(&self) -> usize[src]

Returns scaled height.

pub fn unscaled_width(&self) -> usize[src]

Returns unscaled width.

pub fn unscaled_height(&self) -> usize[src]

Returns unscaled height.

pub fn values(&self) -> &[Scalar][src]

Returns values buffer.

pub fn steepness(&self) -> &[Scalar][src]

Returns steepness buffer.

pub fn value_at_point(&self, point: (isize, isize)) -> Scalar[src]

Returns value at given point or 0 if out of bounds.

Arguments

  • point - (X, Y)

pub fn steepness_at_point(&self, point: (isize, isize)) -> Scalar[src]

Returns steepness at given point or 0 if out of bounds.

Arguments

  • point - (X, Y)

pub fn value_steepness_iter<'a>(
    &'a self
) -> impl Iterator<Item = (usize, usize, Scalar, Scalar)> + 'a
[src]

Returns iterator over values and steepness buffers.

Examples

use density_mesh_core::*;

let map = DensityMap::new(2, 2, 1, vec![2, 2, 4, 4])
    .unwrap()
    .value_steepness_iter()
    .collect::<Vec<_>>();
assert_eq!(
    map,
    vec![
        (0, 0, 0.007843138, 0.011764706),
        (1, 0, 0.007843138, 0.011764707),
        (0, 1, 0.015686275, 0.01633987),
        (1, 1, 0.015686275, 0.01633987),
    ],
);

Trait Implementations

impl Clone for DensityMap[src]

impl Debug for DensityMap[src]

impl<'de> Deserialize<'de> for DensityMap[src]

impl PartialEq<DensityMap> for DensityMap[src]

impl Serialize for DensityMap[src]

impl StructuralPartialEq for DensityMap[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> DeserializeOwned for T where
    T: for<'de> Deserialize<'de>, 
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.