My favorites | Sign in
Project Home Wiki Issues Source
Repository:
Checkout   Browse   Changes   Clones    
 
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
#!/usr/bin/python
#
# Copyright 2009 Scott Kirkwood All Rights Reserved.

"""Make the digits from 0-9

Uses my inkscape extension seven_segments.py
"""

__author__ = 'scott@forusers.com (Scott Kirkwood)'

import optparse
import subprocess
import os

def DoOne(number, template, prefix):
args = ['seven_segment.py', '--number', str(number), template]
print ' '.join(args)
new_svg = subprocess.Popen(args, stdout=subprocess.PIPE).communicate()[0]

outfname = prefix + str(number) + '.svg'
fout = open(outfname, 'w')
fout.write(new_svg)
print 'Created %s' % outfname
fout.close()

def ExportAllPng(subdir):
ls = os.listdir(subdir)
for fname in ls:
if not fname.endswith('.svg'):
continue
filename = os.path.join(subdir, fname)
pngname = filename.replace('.svg', '.png')
args = ['inkscape', '-f', filename, '--export-png', pngname]
print ' '.join(args)
subprocess.call(args)

def Combine(subdir):
args = ['gm', 'montage', '-mode', 'concatenate', '-tile', '20x1']
ls = os.listdir(subdir)
ls.sort()
for fname in ls:
fullname = os.path.join(subdir, fname)
if fname == 'combine.png':
os.unlink(fullname)
continue
if not fname.endswith('.png'):
continue
args.append(fullname)
args.append('spacer.png')
args += [os.path.join(subdir, 'combine.png')]
print ' '.join(args)
subprocess.call(args)

def BuildAll(subdir):
ls = os.listdir(subdir)
for filename in ls:
fname = os.path.join(subdir, filename)
if not os.path.isdir(fname) and fname.endswith('svg'):
basename = os.path.splitext(filename)[0]
newdir = os.path.join(subdir, basename)
if not os.path.exists(newdir):
os.mkdir(newdir)
prefix = os.path.join(newdir, basename + '-')
for num in range(10):
DoOne(num, fname, prefix)
ExportAllPng(newdir)
Combine(newdir)

def Main():
parser = optparse.OptionParser()
parser.add_option('-t', '--template', dest='template', default='seven-segment.svg',
help='The svg template to use')
parser.add_option('--prefix', dest='prefix', default='seven-segment/seven-seg-',
help='The file prefix to use for all output files.')
parser.add_option('--buildall', dest='buildall', action='store_true',
help='Build all styles')
options, args = parser.parse_args()

if options.buildall:
BuildAll('seven-segment')
else:
for number in range(10):
DoOne(number, options.template, options.prefix)


if __name__ == '__main__':
Main()

Change log

9bdf0cc4cc3f by Scott Kirkwood <sc...@forusers.com> on Dec 28, 2009   Diff
Sorted the images so that the number would
appear in a predictable order.
Go to: 
Project members, sign in to write a code review

Older revisions

15d45cc6ba90 by Scott Kirkwood <sc...@forusers.com> on Dec 28, 2009   Diff
Using inkscape to create the images
instead of magick since it does a
better job.
564e7d49dd66 by Scott Kirkwood <scottakirkwood> on Dec 28, 2009   Diff
Untested changes.
Now the green has two paths for the
glow.
Made the default black have a much
less apparent shadow.
f67ef071d545 by Scott Kirkwood <sc...@forusers.com> on Dec 27, 2009   Diff
Added ability to make the montages and
some templates.
All revisions of this file

File info

Size: 2555 bytes, 88 lines
Powered by Google Project Hosting