-
Notifications
You must be signed in to change notification settings - Fork 66
/
drawcurve
executable file
·65 lines (60 loc) · 1.81 KB
/
drawcurve
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
55
56
57
58
59
60
61
62
63
64
65
#!/usr/bin/env python
import os.path, math
import scurve
from scurve import draw
def main():
from optparse import OptionParser, OptionGroup
parser = OptionParser(
usage = "%prog [options] output",
version="%prog 0.1",
)
parser.add_option("-c", "--color", action="store", dest="color", default="0A2376")
parser.add_option(
"-b", "--background", action="store", dest="background", default="FFFFFF"
)
parser.add_option(
"-s", "--size", action="store",
type="int", dest="size", default=100
)
parser.add_option(
"-o", "--order", action="store",
type="int", dest="order", default=None,
help = "Order of the curve."
)
parser.add_option(
"-p", "--points", action="store",
type="int", dest="points", default=None,
help = "Total number of points on the curve."
)
parser.add_option(
"-d", "--dotsize", action="store",
type="int", dest="dotsize", default=2
)
parser.add_option(
"-m", "--mark", action="append",
type="int", dest="mark", default=[]
)
parser.add_option(
"-u", "--curve", action="store",
type="str", dest="curve", default="hilbert"
)
options, args = parser.parse_args()
if len(args) != 1:
parser.error("Please specify output file.")
if options.order:
c = scurve.fromOrder(options.curve, 2, options.order)
elif options.points:
c = scurve.fromSize(options.curve, 2, options.points)
else:
parser.error("Must specify either points or order.")
d = draw.Demo(
c,
options.size,
options.color,
options.background,
options.dotsize,
*options.mark
)
d.draw()
d.save(args[0])
main()