Sophie

Sophie

distrib > Mandriva > 2010.0 > i586 > media > contrib-release > by-pkgid > 789a4dca4953f037223e830336ef4af3 > files > 1084

python-enthought-enable-3.2.0-2mdv2010.0.i586.rpm

from enthought.kiva import GraphicsContext
import numpy

# colors are 5 doubles: offset, red, green, blue, alpha
starting_color = numpy.array([0.0, 1.0, 1.0, 1.0, 1.0])
ending_color = numpy.array([1.0, 0.0, 0.0, 0.0, 1.0])

gc = GraphicsContext((500,500))
gc.clear()
gc.rect(100,100,300,300)
gc.linear_gradient(100, 100, 300, 300,
                    numpy.array([starting_color, ending_color]),
                    2, "")
gc.draw_path()
gc.save("gradient.bmp")