NaaLaa
Pixel Color Test - 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: Pixel Color Test (/thread-117.html)



Pixel Color Test - johnno56 - 04-11-2024

Marcus,

I am still confused in regards to "how" the pixel() command works.

Are you able to explain the output produced? (see attached image)

   

Regards

J


RE: Pixel Color Test - 1micha.elok - 04-12-2024

This is an unofficial answer ... 
(unofficial = might be incomplete or even confusing .... lol ....)

pixel(x,y) returns the color at position (x, y) as an array [r, g, b, a]

Code:
'pixel(x,y) returns the color at position (x, y) as an array [r, g, b, a]
getcolor=pixel(150,150)
wln getcolor
wln
write "RGBA "
for i = 0 to 3
    write getcolor[i]+" "
next

   
click the image to zoom in


RE: Pixel Color Test - johnno56 - 04-12-2024

Ah... this is where my confusion kicks in... over the many years of using multiple forms of Basic, the commands for testing a colour at x,y usual produces a single integer value. If memory serves correctly, N6 handled integer values using "pixeli(x,y)"

So, as N7 currently stands, if I want to check the colour of a pixel, I will need to check all R, G, B and A values of pixel(x,y)? or am I still confused... Would it not be simpler to add pixeli() command to N7?


RE: Pixel Color Test - Marcus - 04-12-2024

(04-12-2024, 10:54 AM)johnno56 Wrote: Ah... this is where my confusion kicks in... over the many years of using multiple forms of Basic, the commands for testing a colour at x,y usual produces a single integer value. If memory serves correctly, N6 handled integer values using "pixeli(x,y)"

So, as N7 currently stands, if I want to check the colour of a pixel, I will need to check all R, G, B and A values of pixel(x,y)? or am I still confused... Would it not be simpler to add pixeli() command to N7?

The problem is that n7 has no integer type, all numbers are 64 bit doubles (floating point). A 64 bit double can correctly represent any signed 32 bit integer. But what you need when storing an RGBA value is a 32 bit UNSIGNED integer with a much larger (positive) range. Can a double handle that, or ... does it even matter if it's just used for a pixeli function? I'm not sure. Do we also want to be able to simulate bit operators? Would that work? I'm not sure Smile

I'll give it a shot anyhow Smile


RE: Pixel Color Test - Marcus - 04-14-2024

I released a new version with the 'pixeli' function and 'set colori' command. I didn't add any bitwise operators but provided some helper functions in the release post. Hope it helps!


RE: Pixel Color Test - johnno56 - 04-14-2024

Cool... I am about to turn in for the evening... I will "take it out for a spin" in the morning... Your efforts are appreciated. Thank you.