Subversion Repositories Kolibri OS

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
6581 leency 1
--PALETTE Set: 3 Bit (8 Primaries)
2
--by Richard Fhager
3
--http://hem.fyristorg.com/dawnbringer/
4
 
5
-- Copyright 2010 Richard Fhager
6
--
7
-- This program is free software; you can redistribute it and/or
8
-- modify it under the terms of the GNU General Public License
9
-- as published by the Free Software Foundation; version 2
10
-- of the License. See 
11
 
12
 
13
-- Generate palette of all colors possible with a given number of shades for each channel
14
-- 2 shades = 1 bit / channel = 3 bit palette = 2^3 colors =  8 colors
15
-- 4 shades = 2 bit / channel = 6 bit palette = 2^6 colors = 64 colors
16
 
17
-- Channel shades (shades = 2 ^ bit-depth)
18
shades = 2
19
 
20
mult = 255 / (shades-1)
21
 
22
 
23
colors = {}
24
col = 0
25
for r = 0, shades-1, 1 do
26
  for g = 0, shades-1, 1 do
27
    for b = 0, shades-1, 1 do
28
       col = col + 1
29
       colors[col] = { r*mult, g*mult, b*mult }
30
    end
31
  end
32
end
33
 
34
 
35
for c = 1, #colors, 1 do
36
 
37
  setcolor(c-1,colors[c][1],colors[c][2],colors[c][3])
38
 
39
end