NaaLaa
Sprite Editor - Printable Version

+- NaaLaa (https://www.naalaa.com/forum)
+-- Forum: NaaLaa (https://www.naalaa.com/forum/forum-1.html)
+--- Forum: NaaLaa 7 Questions (https://www.naalaa.com/forum/forum-3.html)
+--- Thread: Sprite Editor (/thread-178.html)



Sprite Editor - johnno56 - 12-24-2024

I have a listing (N5 or N6 ?) for a sprite editor that I am trying to convert to N7.

There is a command that is used in converting the colour detected by the mouse into an RGB format... That command is 'SHR' (SHift register Right).

Reason: Using pixeli(x, y), to detect the colour, produces a number like:
black = 4278190080
white = 4294967295
red = 4294901760
green = 4278255360
blue = 4278190335

To convert to RGB three functions were used: n_c is the colour detected

rem    ---------------------------------------------------
rem        Convert to RGB format
rem    ---------------------------------------------------
function getB(n_c)
    return n_c AND 255
endfunc   

function getG(n_c)
    return (n_c SHR 8) AND 255
endfunc   

function getR(n_c)
    return (n_c SHR 16) AND 255
endfunc

I need to know if there is a method to replace SHR.


RE: Sprite Editor - Marcus - 12-25-2024

(12-24-2024, 08:55 AM)johnno56 Wrote: I have a listing (N5 or N6 ?) for a sprite editor that I am trying to convert to N7.

There is a command that is used in converting the colour detected by the mouse into an RGB format... That command is 'SHR' (SHift register Right).

Reason: Using pixeli(x, y), to detect the colour, produces a number like:
black = 4278190080
white = 4294967295
red = 4294901760
green = 4278255360
blue = 4278190335

To convert to RGB three functions were used: n_c is the colour detected

rem    ---------------------------------------------------
rem        Convert to RGB format
rem    ---------------------------------------------------
function getB(n_c)
    return n_c AND 255
endfunc   

function getG(n_c)
    return (n_c SHR 8) AND 255
endfunc   

function getR(n_c)
    return (n_c SHR 16) AND 255
endfunc

I need to know if there is a method to replace SHR.

I believe these functions should do it:

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

The parameter sent to these functions should be a value returned by pixeli Smile


RE: Sprite Editor - johnno56 - 12-25-2024

Cool... I had already figured out that I needed to use "pixeli"... the one thing that I had forgotten was the "alpha" component...

Thank you SO much for the assist... I spent most of yesterday trying to figure it out... lol

Enjoy your Christmas!

J

ps: Added the "alpha" component and "colour selection" is finally working. Thank you SO much...