2 # -*- coding: ISO-8859-15 -*-
4 sys
.path
.insert(0, "..")
9 from pyx
.graph
import axis
, data
11 # define some functions for the color values:
12 def red(x
): return 2*x
*(1-x
)**5 + 3.5*x
**2*(1-x
)**3 + 2.1*x
*x
*(1-x
)**2 + 3.0*x
**3*(1-x
)**2 + x
**0.5*(1-(1-x
)**2)
13 def green(x
): return 1.5*x
**2*(1-x
)**3 - 0.8*x
**3*(1-x
)**2 + 2.0*x
**4*(1-x
) + x
**4
14 def blue(x
): return 5*x
*(1-x
)**5 - 0.5*x
**2*(1-x
)**3 + 0.3*x
*x
*(1-x
)**2 + 5*x
**3*(1-x
)**2 + 0.5*x
**6
16 # use the implemented converter for the grey value:
17 def grey(x
): return color
.rgb(red(x
), green(x
), blue(x
)).grey().color
["gray"]
19 # plot the color values
20 g
= graph
.graphxy(width
=10, ratio
=1)
21 g
.plot(data
.function("y(x)=red(x)", min=0, max=1, context
=locals()), [graph
.style
.line([color
.rgb
.red
])])
22 g
.plot(data
.function("y(x)=green(x)", min=0, max=1, context
=locals()), [graph
.style
.line([color
.rgb
.green
])])
23 g
.plot(data
.function("y(x)=blue(x)", min=0, max=1, context
=locals()), [graph
.style
.line([color
.rgb
.blue
])])
24 g
.plot(data
.function("y(x)=grey(x)", min=0, max=1, context
=locals()))
31 g
.fill(path
.rect(x
, -2, 10.5/(n
-1), 1), [color
.rgb(red(t
), green(t
), blue(t
))])
34 g
.writeEPSfile("palettetest", paperformat
=document
.paperformat
.A4
)
35 g
.writePDFfile("palettetest")