CanvasIO.drawImage

Draw an image on the canvas.

drawImage is the usual method, which enables scaling and filtering, likely making it preferable for most images. However, this may harm images that have been generated (like text) or adjusted to display on the user's screen (like icons), so drawHintedImage may be preferrable. For similar reasons, drawHintedImage may also be better for pixel art images.

While specifics of drawImage are left to the implementation, drawHintedImage should directly blit the image or use nearest-neighbor to scale, if needed. Image boundaries should be adjusted to align exactly with the screen's pixel grid.

  1. void drawImage(DrawableImage image, Rectangle destination, Color tint)
    interface CanvasIO
    final nothrow
    void
    drawImage
  2. void drawImage(DrawableImage image, Vector2 destination, Color tint)

Parameters

image DrawableImage

Image to draw. The image must be prepared with Node.load before.

destination Rectangle

Position to place the image's top-left corner at or rectangle to fit the image in. The image should be stretched to fit this box.

tint Color

Color to modulate the image against. Every pixel in the image should be multiplied channel-wise by this color; values 0...255 should be mapped to 0...1.

Meta