Exemple #1
0
def NewColorMap(h):

    ctf = ColorTransferFunction()
    otf = PiecewiseFunction()
    ctf.remove_all_points()
    otf.remove_all_points()
    ctf.add_rgb_point(0, 1, 1, 1)
    otf.add_point(0, 0)
    for i in range(128):
        q = (i + 1.0) / 128.0
        ctf.add_rgb_point(-q, 1 - q * q, 1 - q * q,
                          1)  # -1 --> blue,  0 --> white,  1-->red
        ctf.add_rgb_point(q, 1, 1 - q * q, 1 - q * q)
        otf.add_point(-q, 0.5 * q)
        otf.add_point(q, 0.5 * q)
    ctf.range = [-1, 1]
    h._volume_property.set_color(ctf)
    h._ctf = ctf
    h.update_ctf = True
    h._otf = otf
    h._volume_property.set_scalar_opacity(otf)