Skip to main content

Map

Struct Map 

Source
pub struct Map { /* private fields */ }
Expand description

represents a map assembled from map tiles

Implementations§

Source§

impl Map

Source

pub async fn new( map_tile_cache: &mut MapTileCache, x: u32, y: u32, grid_rectangle: GridRectangle, fill_missing_map_tiles: Option<Rgba<u8>>, fill_missing_regions: Option<Rgba<u8>>, ) -> Result<Self, MapError>

creates a new Map

if we choose not to fill the missing map tiles they appear as black

if we choose not to fill the missing regions they appear in a color similar to water but filling them in has some performance impact since we need to check if the region exists by fetching higher resolution map tiles for it.

§Errors

returns an error if fetching the map tiles fails

§Arguments
  • map_tile_cache - the map tile cache to use to fetch the map tiles
  • x - the width of the map in pixels
  • y - the height of the map in pixels
  • grid_rectangle - the grid rectangle of regions represented by this map
Source

pub async fn draw_route( &mut self, region_name_to_grid_coordinates_cache: &mut RegionNameToGridCoordinatesCache, usb_notecard: &USBNotecard, color: Rgba<u8>, ) -> Result<(), MapError>

draws a route from a USBNotecard onto the map

§Errors

fails if the region name to grid coordinate conversion fails or the conversion of those into pixel coordinates

Source

pub fn save(&self, path: &Path) -> Result<(), ImageError>

saves the map to the specified path

§Errors

returns an error when the image libraries returns an error when saving the image

Trait Implementations§

Source§

impl Clone for Map

Source§

fn clone(&self) -> Map

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for Map

Source§

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

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

impl GenericImage for Map

Source§

fn get_pixel_mut(&mut self, x: u32, y: u32) -> &mut Self::Pixel

👎Deprecated since 0.24.0:

Use get_pixel and put_pixel instead.

Gets a reference to the mutable pixel at location (x, y). Indexed from top left. Read more
Source§

fn put_pixel(&mut self, x: u32, y: u32, pixel: Self::Pixel)

Put a pixel at location (x, y). Indexed from top left. Read more
Source§

fn blend_pixel(&mut self, x: u32, y: u32, pixel: Self::Pixel)

👎Deprecated since 0.24.0:

Use iterator pixels_mut to blend the pixels directly

Put a pixel at location (x, y), taking into account alpha channels
Source§

unsafe fn unsafe_put_pixel(&mut self, x: u32, y: u32, pixel: Self::Pixel)

Puts a pixel at location (x, y). Indexed from top left. Read more
Source§

fn copy_from<O>(&mut self, other: &O, x: u32, y: u32) -> Result<(), ImageError>
where O: GenericImageView<Pixel = Self::Pixel>,

Copies all of the pixels from another image into this image. Read more
Source§

fn copy_from_samples( &mut self, samples: View<&[<Self::Pixel as Pixel>::Subpixel], Self::Pixel>, x: u32, y: u32, ) -> Result<(), ImageError>

Copy pixels from a regular strided matrix of pixels.
Source§

fn copy_within(&mut self, source: Rect, x: u32, y: u32) -> bool

Copies all of the pixels from one part of this image to another part of this image. Read more
Source§

fn sub_image( &mut self, x: u32, y: u32, width: u32, height: u32, ) -> SubImage<&mut Self>
where Self: Sized,

Returns a mutable subimage that is a view into this image. If you want an immutable subimage instead, use GenericImageView::view The coordinates set the position of the top left corner of the SubImage.
Source§

impl GenericImageView for Map

Source§

type Pixel = <DynamicImage as GenericImageView>::Pixel

The type of pixel.
Source§

fn dimensions(&self) -> (u32, u32)

The width and height of this image.
Source§

fn get_pixel(&self, x: u32, y: u32) -> Self::Pixel

Returns the pixel located at (x, y). Indexed from top left. Read more
Source§

fn width(&self) -> u32

The width of this image.
Source§

fn height(&self) -> u32

The height of this image.
Source§

fn in_bounds(&self, x: u32, y: u32) -> bool

Returns true if this x, y coordinate is contained inside the image.
Source§

unsafe fn unsafe_get_pixel(&self, x: u32, y: u32) -> Self::Pixel

Returns the pixel located at (x, y). Indexed from top left. Read more
Source§

fn pixels(&self) -> Pixels<'_, Self>
where Self: Sized,

Returns an Iterator over the pixels of this image. The iterator yields the coordinates of each pixel along with their value
Source§

fn view(&self, x: u32, y: u32, width: u32, height: u32) -> SubImage<&Self>
where Self: Sized,

Returns a subimage that is an immutable view into this image. You can use GenericImage::sub_image if you need a mutable view instead. The coordinates set the position of the top left corner of the view. Read more
Source§

fn try_view( &self, x: u32, y: u32, width: u32, height: u32, ) -> Result<SubImage<&Self>, ImageError>
where Self: Sized,

Returns a subimage that is an immutable view into this image so long as the provided coordinates and dimensions are within the bounds of this Image.
Source§

fn buffer_like( &self, ) -> ImageBuffer<Self::Pixel, Vec<<Self::Pixel as Pixel>::Subpixel>>

Create an empty ImageBuffer with the same pixel type as this image. Read more
Source§

fn buffer_with_dimensions( &self, width: u32, height: u32, ) -> ImageBuffer<Self::Pixel, Vec<<Self::Pixel as Pixel>::Subpixel>>

Create an empty ImageBuffer with different dimensions. Read more
Source§

fn to_pixel_view( &self, ) -> Option<View<&[<Self::Pixel as Pixel>::Subpixel], Self::Pixel>>

If the buffer has a fitting layout, return a canonical view of the samples. Read more
Source§

impl GridRectangleLike for Map

Source§

fn grid_rectangle(&self) -> GridRectangle

the GridRectangle represented by this map like image
Source§

fn lower_left_corner(&self) -> GridCoordinates

returns the lower left corner of the rectangle
Source§

fn lower_right_corner(&self) -> GridCoordinates

returns the lower right corner of the rectangle
Source§

fn upper_left_corner(&self) -> GridCoordinates

returns the upper left corner of the rectangle
Source§

fn upper_right_corner(&self) -> GridCoordinates

returns the upper right corner of the rectangle
Source§

fn size_x(&self) -> u16

the size of the map like image in regions in the x direction (width)
Source§

fn size_y(&self) -> u16

the size of the map like image in regions in the y direction (width)
Source§

fn x_range(&self) -> RangeInclusive<u16>

returns a range for the region x coordinates of this rectangle
Source§

fn y_range(&self) -> RangeInclusive<u16>

returns a range for the region y coordinates of this rectangle
Source§

fn contains(&self, grid_coordinates: &GridCoordinates) -> bool

checks if a given set of GridCoordinates is within this GridRectangle
Source§

fn intersect<O>(&self, other: &O) -> Option<GridRectangle>

returns a new GridRectangle which is the area where this GridRectangle and another intersect each other or None if there is no intersection
Source§

fn pps_hud_config(&self) -> String

returns a PPS HUD description string for this GridRectangle Read more
Source§

impl MapLike for Map

Source§

fn zoom_level(&self) -> ZoomLevel

the zoom level of the map
Source§

fn image(&self) -> &DynamicImage

the image of the map
Source§

fn image_mut(&mut self) -> &mut DynamicImage

the mutable image of the map
Source§

fn pixels_per_meter(&self) -> f32

pixels per meter
Source§

fn pixels_per_region(&self) -> f32

pixels per region
Source§

fn pixel_coordinates_for_coordinates( &self, grid_coordinates: &GridCoordinates, region_coordinates: &RegionCoordinates, ) -> Option<(u32, u32)>

the pixel coordinates in the map that represent the given GridCoordinates and RegionCoordinates
Source§

fn coordinates_for_pixel_coordinates( &self, x: u32, y: u32, ) -> Option<(GridCoordinates, RegionCoordinates)>

the GridCoordinates and RegionCoordinates at the given pixel coordinates
Source§

fn crop_imm_grid_rectangle( &self, grid_rectangle: &GridRectangle, ) -> Option<SubImage<&Self>>
where Self: Sized,

a crop of the map like image by coordinates and size
Source§

fn draw_waypoint(&mut self, x: u32, y: u32, color: Rgba<u8>)

draw a waypoint at the given coordinates
Source§

fn draw_line( &mut self, from_x: u32, from_y: u32, to_x: u32, to_y: u32, color: Rgba<u8>, )

draw a line from the given coordinates to the given coordinates
Source§

fn draw_arrow(&mut self, from: (f32, f32), tip: (f32, f32), color: Rgba<u8>)

draw an arrow from the direction of the first point with the tip at the second point

Auto Trait Implementations§

§

impl Freeze for Map

§

impl RefUnwindSafe for Map

§

impl Send for Map

§

impl Sync for Map

§

impl Unpin for Map

§

impl UnsafeUnpin for Map

§

impl UnwindSafe for Map

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<I> Canvas for I
where I: GenericImage,

Source§

type Pixel = <I as GenericImageView>::Pixel

The type of Pixel that can be drawn on this canvas.
Source§

fn dimensions(&self) -> (u32, u32)

The width and height of this canvas.
Source§

fn get_pixel(&self, x: u32, y: u32) -> <I as Canvas>::Pixel

Returns the pixel located at (x, y).
Source§

fn draw_pixel(&mut self, x: u32, y: u32, color: <I as Canvas>::Pixel)

Draw a pixel at the given coordinates. x and y should be within dimensions - if not then panicking is a valid implementation behaviour.
Source§

fn width(&self) -> u32

The width of this canvas.
Source§

fn height(&self) -> u32

The height of this canvas.
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> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

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

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<SS, SP> SupersetOf<SS> for SP
where SS: SubsetOf<SP>,

Source§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
Source§

fn is_in_subset(&self) -> bool

Checks if self is actually part of its subset T (and can be converted to it).
Source§

fn to_subset_unchecked(&self) -> SS

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
Source§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more