You can now use 'pixeli(x, y)' or 'pixeli(image_id, x, y)' to get the color of an image's pixel as a single number. You can also use 'set colori' to set the current drawing color using such a number.
If you need to convert RGB or RGBA values to a single number color, you can use functions like these:
And to get the RGBA components of a single number color:
2024-04-14
Added the 'pixeli' function and 'set colori' command to get and set colors as single numbers
If you need to convert RGB or RGBA values to a single number color, you can use functions like these:
Code:
function ToRGB(r, g, b)
return 255*16777216 + r*65536 + g*256 + b
endfunc
function ToRGBA(r, g, b, a)
return a*16777216 + r*65536 + g*256 + b
endfunc
And to get the RGBA components of a single number color:
Code:
function Alpha(c)
return int(c/16777216)
endfunc
function Red(c)
return int((c/65536))%256
endfunc
function Green(c)
return int((c/256))%256
endfunc
function Blue(c)
return c%256
endfunc
2024-04-14
Added the 'pixeli' function and 'set colori' command to get and set colors as single numbers