Skip to content

Class endstone::MapCanvas

ClassList > 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.

  • #include <endstone/map/map_canvas.h>

Public Functions

Type Name
virtual void drawImage (int x, int y, const Image & image) = 0
Draw an image to the map. The image will be clipped if necessary.
virtual Color getBasePixelColor (int x, int y) const = 0
Get a pixel from the layers below this canvas.
virtual MapView & getMapView () const = 0
Get the map this canvas is attached to.
virtual std::optional< Color > getPixelColor (int x, int y) const = 0
Get a pixel from the canvas.
virtual void setPixelColor (int x, int y, std::optional< Color > color) = 0
Draw a pixel to the canvas.
virtual ~MapCanvas () = default

Public Functions Documentation

function drawImage

Draw an image to the map. The image will be clipped if necessary.

virtual void endstone::MapCanvas::drawImage (
    int x,
    int y,
    const  Image & image
) = 0

Parameters:

  • x The x coordinate of the image.
  • y The y coordinate of the image.
  • image The Image to draw.

function getBasePixelColor

Get a pixel from the layers below this canvas.

virtual Color endstone::MapCanvas::getBasePixelColor (
    int x,
    int y
) const = 0

Parameters:

  • x The x coordinate, from 0 to 127.
  • y The y coordinate, from 0 to 127.

Returns:

The color.


function getMapView

Get the map this canvas is attached to.

virtual MapView & endstone::MapCanvas::getMapView () const = 0

Returns:

The MapView this canvas is attached to.


function getPixelColor

Get a pixel from the canvas.

virtual std::optional< Color > endstone::MapCanvas::getPixelColor (
    int x,
    int y
) const = 0

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.


function setPixelColor

Draw a pixel to the canvas.

virtual void endstone::MapCanvas::setPixelColor (
    int x,
    int y,
    std::optional< Color > color
) = 0

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.

function ~MapCanvas

virtual endstone::MapCanvas::~MapCanvas () = default


The documentation for this class was generated from the following file include/endstone/map/map_canvas.h