pub struct Map { /* private fields */ }Expand description
represents a map assembled from map tiles
Implementations§
Source§impl Map
impl Map
Sourcepub 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>
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 tilesx- the width of the map in pixelsy- the height of the map in pixelsgrid_rectangle- the grid rectangle of regions represented by this map
Sourcepub async fn draw_route(
&mut self,
region_name_to_grid_coordinates_cache: &mut RegionNameToGridCoordinatesCache,
usb_notecard: &USBNotecard,
color: Rgba<u8>,
) -> Result<(), MapError>
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
Trait Implementations§
Source§impl GenericImage for Map
impl GenericImage for Map
Source§fn get_pixel_mut(&mut self, x: u32, y: u32) -> &mut Self::Pixel
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 moreSource§fn put_pixel(&mut self, x: u32, y: u32, pixel: Self::Pixel)
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)
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)
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>,
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>
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
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,
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
impl GenericImageView for Map
Source§type Pixel = <DynamicImage as GenericImageView>::Pixel
type Pixel = <DynamicImage as GenericImageView>::Pixel
The type of pixel.
Source§fn dimensions(&self) -> (u32, u32)
fn dimensions(&self) -> (u32, u32)
The width and height of this image.
Source§fn get_pixel(&self, x: u32, y: u32) -> Self::Pixel
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 in_bounds(&self, x: u32, y: u32) -> bool
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
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,
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,
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 moreSource§fn try_view(
&self,
x: u32,
y: u32,
width: u32,
height: u32,
) -> Result<SubImage<&Self>, ImageError>where
Self: Sized,
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>>
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 moreSource§fn buffer_with_dimensions(
&self,
width: u32,
height: u32,
) -> ImageBuffer<Self::Pixel, Vec<<Self::Pixel as Pixel>::Subpixel>>
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 moreSource§impl GridRectangleLike for Map
impl GridRectangleLike for Map
Source§fn grid_rectangle(&self) -> GridRectangle
fn grid_rectangle(&self) -> GridRectangle
the
GridRectangle represented by this map like imageSource§fn lower_left_corner(&self) -> GridCoordinates
fn lower_left_corner(&self) -> GridCoordinates
returns the lower left corner of the rectangle
Source§fn lower_right_corner(&self) -> GridCoordinates
fn lower_right_corner(&self) -> GridCoordinates
returns the lower right corner of the rectangle
Source§fn upper_left_corner(&self) -> GridCoordinates
fn upper_left_corner(&self) -> GridCoordinates
returns the upper left corner of the rectangle
Source§fn upper_right_corner(&self) -> GridCoordinates
fn upper_right_corner(&self) -> GridCoordinates
returns the upper right corner of the rectangle
Source§fn x_range(&self) -> RangeInclusive<u16>
fn x_range(&self) -> RangeInclusive<u16>
returns a range for the region x coordinates of this rectangle
Source§fn y_range(&self) -> RangeInclusive<u16>
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
fn contains(&self, grid_coordinates: &GridCoordinates) -> bool
checks if a given set of
GridCoordinates is within this GridRectangleSource§fn intersect<O>(&self, other: &O) -> Option<GridRectangle>where
O: GridRectangleLike,
fn intersect<O>(&self, other: &O) -> Option<GridRectangle>where
O: GridRectangleLike,
returns a new
GridRectangle which is the area where this GridRectangle
and another intersect each other or None if there is no intersectionSource§fn pps_hud_config(&self) -> String
fn pps_hud_config(&self) -> String
returns a PPS HUD description string for this
GridRectangle Read moreSource§impl MapLike for Map
impl MapLike for Map
Source§fn zoom_level(&self) -> ZoomLevel
fn zoom_level(&self) -> ZoomLevel
the zoom level of the map
Source§fn image(&self) -> &DynamicImage
fn image(&self) -> &DynamicImage
the image of the map
Source§fn image_mut(&mut self) -> &mut DynamicImage
fn image_mut(&mut self) -> &mut DynamicImage
the mutable image of the map
Source§fn pixels_per_meter(&self) -> f32
fn pixels_per_meter(&self) -> f32
pixels per meter
Source§fn pixels_per_region(&self) -> f32
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)>
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 RegionCoordinatesSource§fn coordinates_for_pixel_coordinates(
&self,
x: u32,
y: u32,
) -> Option<(GridCoordinates, RegionCoordinates)>
fn coordinates_for_pixel_coordinates( &self, x: u32, y: u32, ) -> Option<(GridCoordinates, RegionCoordinates)>
the
GridCoordinates and RegionCoordinates at the given pixel coordinatesSource§fn crop_imm_grid_rectangle(
&self,
grid_rectangle: &GridRectangle,
) -> Option<SubImage<&Self>>where
Self: Sized,
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>)
fn draw_waypoint(&mut self, x: u32, y: u32, color: Rgba<u8>)
draw a waypoint at the given coordinates
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<I> Canvas for Iwhere
I: GenericImage,
impl<I> Canvas for Iwhere
I: GenericImage,
Source§type Pixel = <I as GenericImageView>::Pixel
type Pixel = <I as GenericImageView>::Pixel
The type of
Pixel that can be drawn on this canvas.Source§fn dimensions(&self) -> (u32, u32)
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
fn get_pixel(&self, x: u32, y: u32) -> <I as Canvas>::Pixel
Returns the pixel located at (x, y).
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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 moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
The inverse inclusion map: attempts to construct
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
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
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
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self to the equivalent element of its superset.