#!/usr/bin/env python

from web_graphics import gradient, RADIAL, NO_NOISE, get_pixel_intensities

from itertools import izip_longest
import numpy as np

def grouper(n, iterable, fillvalue=None):
    "grouper(3, 'ABCDEFG', 'x') --> ABC DEF Gxx"
    args = [iter(iterable)] * n
    return izip_longest(fillvalue=fillvalue, *args)

width = 100
height = 100

img = get_pixel_intensities(width, height, gradient(RADIAL(0.5, 0.5), NO_NOISE,
    [(1.0, (0xDD, 0xDD, 0xDD), (0x10, 0x12, 0x13)),]))

img = np.array([sum(group) for group in (grouper(3, img, 0))])
img *= (255/img.max())

import pylab

img_ = img.reshape(width, height)
pylab.axis('off')
pylab.gray()
pylab.imshow(img_)
pylab.show()
示例#2
0
#!/usr/bin/env python

from web_graphics import write_png, gradient, LINEAR_X, LINEAR_Y, RADIAL, NO_NOISE, GAUSSIAN, HSV

## EXAMPLES

# normally you would make these with width=1 but below I've made them 50
# so you can more easily see the result

# body background from old jtauber.com and quisition.com
write_png("example1.png", 50, 143, gradient(LINEAR_Y, NO_NOISE, [(1.0, (0xA1, 0xA1, 0xA1), (0xDF, 0xDF, 0xDF))]))

# header background similar to that on old jtauber.com
write_png(
    "example2.png",
    50,
    90,
    gradient(
        LINEAR_Y,
        NO_NOISE,
        [
            (0.43, (0xBF, 0x94, 0xC0), (0x4C, 0x26, 0x4C)),  # top
            (0.85, (0x4C, 0x26, 0x4C), (0x27, 0x13, 0x27)),  # bottom
            (1.00, (0x66, 0x66, 0x66), (0xFF, 0xFF, 0xFF)),  # shadow
        ],
    ),
)

# original header gradient from pinax
write_png(
    "example3.png",
示例#3
0
#!/usr/bin/env python

from web_graphics import write_png, gradient, LINEAR_X, LINEAR_Y, RADIAL, NO_NOISE, GAUSSIAN, HSV

## EXAMPLES

# normally you would make these with width=1 but below I've made them 50
# so you can more easily see the result

# body background from old jtauber.com and quisition.com
write_png(
    "example1.png", 50, 143,
    gradient(LINEAR_Y, NO_NOISE, [
        (1.0, (0xA1, 0xA1, 0xA1), (0xDF, 0xDF, 0xDF)),
    ]))

# header background similar to that on old jtauber.com
write_png(
    "example2.png",
    50,
    90,
    gradient(
        LINEAR_Y,
        NO_NOISE,
        [
            (0.43, (0xBF, 0x94, 0xC0), (0x4C, 0x26, 0x4C)),  # top
            (0.85, (0x4C, 0x26, 0x4C), (0x27, 0x13, 0x27)),  # bottom
            (1.00, (0x66, 0x66, 0x66), (0xFF, 0xFF, 0xFF)),  # shadow
        ]))

# original header gradient from pinax