Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
n7 version 24.04.14 released
#1
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
Reply
#2
There are examples of all these functions in the package
Reply
#3
(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.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)