android
  #1  
Old 12-06-2010, 06:17 PM
jbob182's Avatar
jbob182 jbob182 is offline
X-Fi2 Development Moderator
 
Join Date: Feb 2010
Location: The U.S.A.
Posts: 554
Default Color Format

I have been testing with colors and got a strange format where 0+=white,-9000000000- is black. Does anyone know how colors can be found in this format (yes it works on the player) i will release a simple fading app to prove the concept ( it goes starting off green bright then fading to dark green then going to the next type of green and shades that if you need it faster change the libs.lua file.

Note it will stay on one color for a while due to the way i have it go through the possible numbers, but it does transist the colors

after a bit more testing i got these values



Code:
  255,0,0 =-65536                  255,0,255= -65281
  255,0,1=-65282                  255,255,255=-1
  1,1,1=-16711423                100,100,100 =-10197916
is it just how the lua player handles colors? by converting them to a custom format

might it be access values?

http://cloford.com/resources/colours/500col.htm


----------------------------

i just found that i put this in the wrong section, could an adim move it ( i dont think i can)
Attached Files
File Type: zip Color Proof.zip (958 Bytes, 14 views)

Last edited by jbob182; 12-06-2010 at 07:12 PM.
Reply With Quote

Advertisement [Remove Advertisement]

  #2  
Old 12-06-2010, 07:27 PM
Brett_val's Avatar
Brett_val Brett_val is offline
Senior Member
 
Join Date: Jan 2010
Location: The Netherlands
Posts: 636
Default

How did you discover this?? Could be those colorcodes you linked. This may be much easier to use than r,g,b since you don't need the commas.

I'm writing all the values to a textfile with your app, I'll post when done.

Here's the first part of the file.. It getting bigger and bigger but this first part draws the picture clear enough I think:
Code:
count    alpha    R    G    B

-4    255    255    255    252
-8    255    255    255    248
-12    255    255    255    244
-16    255    255    255    240
-20    255    255    255    236
-24    255    255    255    232
-28    255    255    255    228
-32    255    255    255    224
-36    255    255    255    220
-40    255    255    255    216
-44    255    255    255    212
and then later:
Code:
-65524    255    255    0    12
-65528    255    255    0    8
-65532    255    255    0    4
-65536    255    255    0    0
-65540    255    254    255    252
-65544    255    254    255    248
-65548    255    254    255    244
-65552    255    254    255    240
256*256=65536

Total possible colors is then 256*256*256=16777216 ~16million colors

Maybe this is the way Lua handles colors? It's definitely much easier to create random colors this way.

PS another example with a number you found:
100,100,100 =-10197916
add all the combinations that have passed:
(256-101)*256*256 + (256-101)*256 + (256-100) =
155*256*256 + 155*256 + 156 =
10158080 + 39680 + 156 = 10197916

Edit2
I was playing with it and wrote a function to calculate codes/RGB.. not sure why it would be useful, but here is it anyway: (it can possibly be a lot simpler as well, if anyone wants to change it, feel free)
Code:
function toCode(colour)
    return -( ( (255-color.r(colour)) *256^2) + ( (255-color.g(colour)) *256) + (256-color.b(colour)) )
end

function toRGB(code)
    return 256 + math.floor(code / 256^2), math.floor((code+1-(math.floor(code / 256^2))*256^2) / 256 ), code - (math.floor(code / 256^2)* (256^2) ) - (math.floor((code+1-(math.floor(code / 256^2))*256^2) / 256 )* 256)
end
print(toRGB(toCode(color.new(1,2,3)))) --prints 1,2,3
__________________
this is a link to my personal homepage which I haven't

Last edited by Brett_val; 12-06-2010 at 09:01 PM.
Reply With Quote

  #3  
Old 12-06-2010, 09:11 PM
jbob182's Avatar
jbob182 jbob182 is offline
X-Fi2 Development Moderator
 
Join Date: Feb 2010
Location: The U.S.A.
Posts: 554
Default

here is a proof : i will enter 10,234,125 and should get
-16 127 618

the result was:
-16 127 618

how to did this was by using this eqaution:


a=125
b=234
c=10

counts=((256-a) + ((256-b) * 256) +((256-c)*65536))*-1)

Last edited by jbob182; 12-08-2010 at 07:08 AM.
Reply With Quote

  #4  
Old 12-06-2010, 09:26 PM
jbob182's Avatar
jbob182 jbob182 is offline
X-Fi2 Development Moderator
 
Join Date: Feb 2010
Location: The U.S.A.
Posts: 554
Default

Darn, Bret_val uploaded his equation like 30 seconds before i put up mine

Quote:
How did you discover this??
I was making a layout of lunar command, i was trying a new style for prograaming ( look at my draw function), and i needed to debug my fillrect so i printed my rgb value and there was the strange format. I have also found some very intersting info on image.setbg() when i was running some test on it like getting an interger to return instead of an image file after i set an image using that function.

This fading effect will be good for lunar command aka missle command
http://www.classicgamesarcade.com/ga...e-command.html

Last edited by jbob182; 12-06-2010 at 09:44 PM.
Reply With Quote

  #5  
Old 12-06-2010, 10:32 PM
Brett_val's Avatar
Brett_val Brett_val is offline
Senior Member
 
Join Date: Jan 2010
Location: The Netherlands
Posts: 636
Default

Funny how you can sometimes just run into things that may be quite useful

The alpha values don't change, right? Or can you set that with codes as well? Because I don't really get how you could fade a color with his. If you start with a color, say, -100255 and then count to -100000, you'd only be changing the blue portion, so how do you want to use this in a fading function?

And what does image.setbg() do? The wiki has nothing about that..

Missilecommand is cool! I thought of it before but I couldn't figure out how to do the controls, so I left it. But I'm looking forward to that one
__________________
this is a link to my personal homepage which I haven't
Reply With Quote

  #6  
Old 12-07-2010, 07:06 AM
jbob182's Avatar
jbob182 jbob182 is offline
X-Fi2 Development Moderator
 
Join Date: Feb 2010
Location: The U.S.A.
Posts: 554
Default

I am going to run some test on alpha soon, our eqautions work for an alpha of 255, there is probably just a missing plus sign and a 256-d * something. For controls why not just touch screen?. I am not talking about true fading but if you look at the shots you fire they go from red to orange.

right now image.stbg() seems useless

if you

print(imagefile:setbg()) you get an interger of 1 to return, i know i did more test on this but i can not remember what they were
Reply With Quote

  #7  
Old 12-07-2010, 03:48 PM
jbob182's Avatar
jbob182 jbob182 is offline
X-Fi2 Development Moderator
 
Join Date: Feb 2010
Location: The U.S.A.
Posts: 554
Default

Here is the alpha eqation

r=color r
b = color b
g = color g
a = alpha

((((256-a)*16777216)(256-r)*65536)+((256-g)*256)+(256-b) *-1)

Last edited by jbob182; 12-08-2010 at 07:08 AM.
Reply With Quote

  #8  
Old 12-09-2010, 07:46 AM
Brett_val's Avatar
Brett_val Brett_val is offline
Senior Member
 
Join Date: Jan 2010
Location: The Netherlands
Posts: 636
Default

Ah it does work with alpha channel, cool. Guess my functions above are useless now since I didn't account for that.

I think it would be really nice for the color transitions!
__________________
this is a link to my personal homepage which I haven't
Reply With Quote

Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump



All times are GMT -5. The time now is 10:32 AM.