コード例 #1
0
ファイル: examples.py プロジェクト: log0ymxm/graphics
#!/usr/bin/env python

from 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 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 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.0,  (0x66, 0x66, 0x66), (0xFF, 0xFF, 0xFF)), # shadow
]))

# original header gradient from pinax
write_png("example3.png", 50, 80, gradient(LINEAR_Y, NO_NOISE, [
    (0.72, (0x00, 0x26, 0x4D), (0x00, 0x40, 0x80)),
    (1.0,  (0x00, 0x40, 0x80), (0x00, 0x6C, 0xCF)), # glow
]))

# form input background from pinax
write_png("example4.png", 50, 25, gradient(LINEAR_Y, NO_NOISE, [
    (0.33, (0xDD, 0xDD, 0xDD), (0xF3, 0xF3, 0xF3)), # top-shadow
    (1.0,  (0xF3, 0xF3, 0xF3), (0xF3, 0xF3, 0xF3)),
コード例 #2
0
from graphics import write_png, gradient, LINEAR_X, LINEAR_Y, RADIAL, NO_NOISE, GAUSSIAN, HSV

write_png("box1.png", 100, 200, gradient(LINEAR_Y, NO_NOISE, [
    (1, (0xF7, 0xF7, 0xF7), (0x98, 0x9A, 0x9E)),
]))

write_png("box2.png", 1, 60, gradient(LINEAR_Y, NO_NOISE, [
    (1, (0xF7, 0xF7, 0xF7), (0xDD, 0xDE, 0xDF)),
]))

write_png("footer.png", 100, 100, gradient(LINEAR_Y, GAUSSIAN(0.01), [
    (0.1, (0x00, 0x00, 0x00), (0x11, 0x11, 0x11)),
    (1, (0x11, 0x11, 0x11), (0x22, 0x22, 0x22)),
]))

write_png("nav.png", 1, 100, gradient(LINEAR_Y, NO_NOISE, [
    (1, (0x11, 0x11, 0x11), (0x66, 0x66, 0x66)),
]))