Calculator Community > Lua

Greyscale on Nspire/CAS

(1/2) > >>

Chirlian:
Am looking for any info about the greyscale that the clickpad/touchpad nspires are using with their b/w lcd. Not much what I find. A greyscale prog I could find, but it works only with Ndless. So how can someone use the greyscale in progs without info about the relation of r/g/b values to grescale 0-15? Ok, not really useful to search longer, I am writing such a program in Lua that shows this values and the related grey by a simple grafik. Am sure that a used coder would do it in shortest time, however, it's a good start for first steps in Lua. But: is there anywhere the info about the r/g/b values of the greyscale?

Adriweb:
RGB stands for Red Green Blue. More info here: https://en.wikipedia.org/wiki/RGB_color_model
So, to get grey, assign the same value for the 3 colors. They range from 0 to 255 (0xff in hexadecimal)

Grey gradient:

--- Code: ---function on.paint(gc)
    for i=0,255 do
        gc:setColorRGB(i,i,i)
        gc:drawLine(i, 0, i, 200) -- using the same variable for the position because I'm lazy
    end
end
--- End code ---



More info about Nspire-Lua on https://wiki.inspired-lua.org for an API doc, and http://compasstech.com.au/TNS_Authoring/Scripting/ for tutorials

Chirlian:
Hi,
thanks for this info, but that is already clear for me (as radio/tv technician it should :-) ). My question is: to which of the 16 gray stages are which r/g/b values related? Up to now I see that this 16 greys are not spreaded over the 8 bit (would mean all 16 bit are a quant to next grey stage) but at about 176 I see the grafik starting to get a little lighter. And this seems to be spreaded over red and green, but blue seems not affected (am just trying this,may be it's not correct). So I am still looking which grey needs which r/g/(b) value. Should be a simple question but also at this lua pages (and TI pages) I didn't find any info about this.

Chirlian:
Hi,
now everything (about this theme) is clear to me. I was experimenting with the single colors of r/g/b (because at b/w lcd they ever must show any grey). But your hint with setting them synchron makes is simple. Starting at 0, then 16 and 32 for all 3 colors I can't see any change on my clickpad display. Then at higher values I can see getting the grafik lighter. Theoretically the change must be at 64, 80, 96 and so on, but it's difficult to see this exactly. However, my question is answered, thank you! So it's very simple to get every grey value as wanted.

Jens_K:
Hi,
even though it seems like your problem was solved, I think I can still give some more useful information about this topic:
I messed around with the grayscaling of the emulator and found out that the Nspire (at least the emulator) apparently uses the commonly used RGB-channel weighting of 0.299*R + 0.587*G + 0.114*B. You can see that on the attached screenshot (even though the emulator seems to mess up certain RGB-values like 0,129,0). Based on this and the fact that the Nspire can display 16 different shades of gray, I assume that the Nspire calculates the displayed shade like this:

--- Code: ---shade = floor((0.299 * R + 0.587 * G + 0.114 * B) / 16)
--- End code ---
I can't test if that's the case myself because I don't own a grayscale Nspire, but this would explain your confusion with single colors of r/g/b.  ;)

Navigation

[0] Message Index

[#] Next page

Go to full version