Skip to Content
⚠ Under Construction
ReferenceC++ APIMapCanvas

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:

NameDescription
drawImageDraw an image to the map. The image will be clipped if necessary.
getBasePixelGet a pixel from the layers below this canvas.
getBasePixelColorGet a pixel from the layers below this canvas.
getMapViewGet the map this canvas is attached to.
getPixelGet a pixel from the canvas.
getPixelColorGet a pixel from the canvas.
setPixelDraw a pixel to the canvas.
setPixelColorDraw 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.
Last updated on