python script to show gamma values
This commit is contained in:
parent
5becf42fbf
commit
967bad8f6d
21
tools/palette_gamma.py
Executable file
21
tools/palette_gamma.py
Executable file
@ -0,0 +1,21 @@
|
|||||||
|
#!/usr/bin/env python
|
||||||
|
# vim:expandtab:ts=2 sw=2:
|
||||||
|
#
|
||||||
|
# show the 8bit values of 16 color palette with gamma correction
|
||||||
|
# Used to build Thomson palettes
|
||||||
|
#
|
||||||
|
# (c) 2018 Thomas BERNARD
|
||||||
|
|
||||||
|
import sys
|
||||||
|
|
||||||
|
def palette_values(n, gamma):
|
||||||
|
return [int(round(255.0*pow(i/(n-1.0), 1.0/gamma))) for i in range (0,n)]
|
||||||
|
|
||||||
|
def array_to_c(a):
|
||||||
|
return '{ ' + ', '.join(a) + '};'
|
||||||
|
|
||||||
|
for i in range (0,22):
|
||||||
|
gamma = 1.0 + i / 10.0
|
||||||
|
p = palette_values(16, gamma)
|
||||||
|
print gamma, array_to_c(map(str, p))
|
||||||
|
print ' ', array_to_c(map(hex, p))
|
||||||
Loading…
x
Reference in New Issue
Block a user