3 from math
import sin
, cos
, pi
8 def colour_cycle(points
, fn
=cos
):
10 for i
in range(points
):
11 a
= i
* 2.0 * pi
/ points
13 _g
= fn(a
+ pi
* 2 / 3.0)
14 _b
= fn(a
+ pi
* 4 / 3.0)
16 r
= (int(255.99 * (_r
+ 1) * 0.5))
17 g
= (int(255.99 * (_g
+ 1) * 0.5))
18 b
= (int(255.99 * (_b
+ 1) * 0.5))
20 colours
.append((r
, g
, b
))
23 def hex_format(colours
):
24 return ["%02x%02x%02x" % x
for x
in colours
]
26 def html_test(colours
):
29 rgb
= "#%02x%02x%02x" % c
30 print '<div style="width:100%%; height:30px; background: %s">' % (rgb
, )
33 print '</body></html>'
35 def cformat(colours
, name
, wrap
=75, unused
=True):
36 # convert to 32bit mask by replicating first couplet as last
37 # the mask will work whether the format is RGB_, _RGB, BGR_, or _BGR
38 table
= ['0x%02x%02x%02x%02x' % (c
[2], c
[0], c
[1], c
[2]) for c
in colours
]
39 table
.append('0x000000')
44 outs
.extend(("static const guint32 %s [%s] = {" % (name
, len(table
)),
47 if len(outs
[-1]) >= wrap
:
49 outs
.append(' %s' % v
)
51 outs
[-1] += ', %s' % v
58 c
= colour_cycle(POINTS
)
61 cformat(c
, "lag_false_colour")