NaaLaa
n7 version 24.04.14 released - Printable Version

+- NaaLaa (https://www.naalaa.com/forum)
+-- Forum: NaaLaa (https://www.naalaa.com/forum/forum-1.html)
+--- Forum: Announcements (https://www.naalaa.com/forum/forum-2.html)
+--- Thread: n7 version 24.04.14 released (/thread-118.html)



n7 version 24.04.14 released - Marcus - 04-14-2024

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:

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


RE: n7 version 24.04.14 released - aliensoldier - 04-15-2024

There are examples of all these functions in the package


RE: n7 version 24.04.14 released - Marcus - 04-15-2024

(04-15-2024, 02:08 PM)aliensoldier Wrote: There are examples of all these functions in the package

Nope, I forgot to write examples for 'pixeli' and 'colori', was kind of a quick fix for johnno.