Skip to content
Swifter edited this page Oct 19, 2024 · 1 revision

ReMapper provides an Image class which allows you to quickly create images from code, typically for debug purposes.


Start with creating an image with rm.image

const image = rm.image(128, 128)

You can set the color of certain pixels with the setPixel function. Let's loop through the image and create a simple gradient on the X and Y axis.

for (let x = 0; x < image.width; x++) {
    for (let y = 0; y < image.height; y++) {
        const red = x / image.width
        const green = y / image.height
        const color: rm.ColorVec = [red, green, 0]

        image.setPixel(x, y, color)
    }
}

Finally, let's save the image.

image.save('my_image.png')

alt text

Clone this wiki locally