endstone::MapCanvas
Represents a canvas for drawing to a map. Each canvas is associated with a specific MapRenderer and represents that renderer’s layer on the map.
Functions:
Name | Description |
---|---|
drawImage | Draw an image to the map. The image will be clipped if necessary. |
getBasePixel | Get a pixel from the layers below this canvas. |
getBasePixelColor | Get a pixel from the layers below this canvas. |
getMapView | Get the map this canvas is attached to. |
getPixel | Get a pixel from the canvas. |
getPixelColor | Get a pixel from the canvas. |
setPixel | Draw a pixel to the canvas. |
setPixelColor | Draw a pixel to the canvas. |
drawImage
void drawImage(int x, int y, const Image &image)
Draw an image to the map. The image will be clipped if necessary.
Parameters:
x
The x coordinate of the image.y
The y coordinate of the image.image
The Image to draw.
getBasePixel
int getBasePixel(int x, int y) const
Get a pixel from the layers below this canvas.
Parameters:
x
The x coordinate, from 0 to 127.y
The y coordinate, from 0 to 127.
Returns:
The color.
getBasePixelColor
Color getBasePixelColor(int x, int y) const
Get a pixel from the layers below this canvas.
Parameters:
x
The x coordinate, from 0 to 127.y
The y coordinate, from 0 to 127.
Returns:
The color.
getMapView
MapView &getMapView() const
Get the map this canvas is attached to.
Returns:
The MapView this canvas is attached to.
getPixel
int getPixel(int x, int y) const
Get a pixel from the canvas.
Parameters:
x
The x coordinate, from 0 to 127.y
The y coordinate, from 0 to 127.
Returns:
The color.
getPixelColor
std::optional<Color> getPixelColor(int x, int y) const
Get a pixel from the canvas.
If no color is set at the given position for this canvas, then std::nullopt is returned and the color returned by getBasePixelColor() is shown on the map.
Parameters:
x
The x coordinate, from 0 to 127.y
The y coordinate, from 0 to 127.
Returns:
The color, or std::nullopt if no color is set.
setPixel
void setPixel(int x, int y, int color)
Draw a pixel to the canvas.
Parameters:
x
The x coordinate, from 0 to 127.y
The y coordinate, from 0 to 127.color
The color.
setPixelColor
void setPixelColor(int x, int y, std::optional<Color> color)
Draw a pixel to the canvas.
If std::nullopt is used as color, then the color returned by getBasePixelColor() is shown on the map.
Parameters:
x
The x coordinate, from 0 to 127.y
The y coordinate, from 0 to 127.color
The color, or std::nullopt for base color.