Skip to content

Colors of the lua gui.* API are incorrect #712

@Perdu

Description

@Perdu

(Continuation of the Discord discussion)

Colors printed by the different gui.* functions of the Lua API seem to me to be incorrect compared to their provided value.

I initialy spotted that by trying to draw a rectangle the same color as this game's wall (0x797988 color), but the following code draw a incorrect color (0xb7b7c1): gui.rectangle(410, 577, 380, 22, 1, 0xff797988, 1) (bottom right rectangle)

Image

To investigate further, I made two scripts: one that would draw all greyscale colors from 0 to 255 in python using matplotlib, one with libTAS. As you can see, libTAS clearly draws a wider ranger of lighter colors (python is left, libTAS is right):

Image

My guess is an incorrect decimal - hexadecimal conversion somewhere.

For completeness, Python code:

import numpy as np
import matplotlib.pyplot as plt

band_height = 4
width = 800

height = 256 * band_height
img = np.zeros((height, width, 3), dtype=np.uint8)

for i in range(256):
    img[i*band_height:(i+1)*band_height, :, :] = i

plt.figure(figsize=(8, 10))
plt.imshow(img)
plt.axis("off")
plt.title("Grayscale bands (0–255)")
plt.show()

libTAS lua code:

function onPaint()
    local bandHeight = 4
    local screenWidth = 100

    for i = 0, 255 do
        local grey = i
        local color =
            0xFF000000 |      -- alpha = 255
            (grey << 16) |    -- red
            (grey << 8)  |    -- green
            grey              -- blue

        local y = 50 + i * bandHeight / 2

        for dy = 0, bandHeight do
            gui.line(100, y, 100 + screenWidth, y + dy, color)
        end
    end
end

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions