forked from cortesi/scurve
-
Notifications
You must be signed in to change notification settings - Fork 0
/
testpattern
executable file
·55 lines (48 loc) · 1.48 KB
/
testpattern
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#!/usr/bin/env python
import os.path, math
import scurve
from scurve import progress
import Image, ImageDraw
def drawmap(map, csource, name, quiet):
c = Image.new("RGB", map.dimensions())
cd = ImageDraw.Draw(c)
step = len(csource)/float(len(map))
if quiet:
prog = progress.Dummy()
else:
prog = progress.Progress(len(map))
for i, p in enumerate(map):
color = csource.point(int(i*step))
cd.point(tuple(p), fill=tuple(color))
if not i%100:
prog.tick(i)
c.save(name)
def main():
from optparse import OptionParser, OptionGroup
parser = OptionParser(
usage = "%prog [options] output",
version="%prog 0.1",
)
parser.add_option(
"-c", "--colorsource", action="store",
type="str", dest="colorsource", default="hilbert"
)
parser.add_option(
"-m", "--map", action="store",
type="str", dest="map", default="hilbert"
)
parser.add_option(
"-s", "--size", action="store",
type="int", dest="size", default=512
)
parser.add_option(
"-q", "--quiet", action="store_true",
dest="quiet", default=False
)
options, args = parser.parse_args()
if len(args) != 1:
parser.error("Please specify output file.")
csource = scurve.fromSize(options.colorsource, 3, 256**3)
map = scurve.fromSize(options.map, 2, options.size**2)
drawmap(map, csource, args[0], options.quiet)
main()