Skip to content

đŸ–ŧī¸ Image module

Features for rendering images

đŸ”ĸ Types

type ImageEmbed struct {
    Filesystem embed.FS
    Image      string
}

ℹī¸ Usage

Note

For this you will need a renderer initialized.

First, load an image using LoadImage() and specify file path, pos X and Y, width, and height.

image := renderer.LoadImage("path/to/image.png", 10, 10, 50, 50) // returns an Image (internal type)

Then, whenever you feel like it, draw it. Just make sure to do it inside the game loop.

image.Draw() // renders your image

We recommend using raw paths, however, heads up as they won't work on the web.

For supporting web, you'll need to use the same func, but passing an ImageEmbed instead of a raw path. See the ImageEmbed struct under here.

var embeddedFiles embed.FS

imageEmbed := vuelto.ImageEmbed{
    Filesystem: embeddedFiles,
    Image:      "image.png",
}

image := renderer.LoadImage(imageEmbed, 0, 0, 1, 1)

And then you can draw it as usual.

image.Draw()