-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathprep_svg
executable file
·180 lines (161 loc) · 11 KB
/
prep_svg
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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
#! /bin/sh
# Code to take the raw svg images exported from Fritzing, and do automatic
# adjustments on them. Typically this is to add text that the svg export dropped.
# If any either automatic or manual corrections are need to an image file, this
# script will create a raw/«name»-fix.svg file. Otherwise the original
# raw/«name».svg is left alone.
# CIRC-01
cp raw/CIRC01_bb.svg raw/CIRC01_bb-fix.svg
# manually add the longest lead arrow using Inkscape: width=2.5
#
# Put back the text that Fritzing svg export dropped off the schematic
# Have not found an svgo option to consolidate transform and coordinate attribuees,
# and have not found a way to get text attributes moved to parent group element.
# Need to include the y value from the text element in the inserted tspans to
# get things to position correctly.
# s «delimi»«regexp»«delimi»«replacement»«delimi»«flags»
sed '
s^>LED</text>^>LED<tspan font-size="4" x="0" y="8.25">(light emitting diode)</tspan><tspan font-size="4" x="7" y="-6">longer lead</tspan><tspan font-size="6" x="-12" y="-19">Arduino</tspan></text>^
s^>gnd</text>^>gnd<tspan font-size="4" x="0" y="9.25">(ground) (-)</tspan></text>^
s^>resistor</text>^>resistor<tspan font-size="4" x="0" y="13.25">(green-blue-brown)</tspan></text>^
' raw/CIRC01_schem.svg >raw/CIRC01_schem-fix.svg
# This does not fix the inverted text, so need to do that manually:
# Manually (text editor) remove the x,y coordinates for the Pin «n» text. and the
# matrix entry for the containing group, then use Inkscape to reposition the text
# Still need to insert the "longer lead" line and arrow as well.
# CIRC-02
cp raw/CIRC02_bb.svg raw/CIRC02_bb-fix.svg
# manually add the longest lead arrow using Inkscape
cp raw/CIRC02_schem.svg raw/CIRC02_schem-fix.svg
# fix the inverted pin number text
# Manually (text editor) remove the x,y coordinates for the Pin «n» text. and the
# matrix entry for the containing group, then use Inkscape to reposition the text
# CIRC-03
cp raw/CIRC03_bb.svg raw/CIRC03_bb-fix.svg
# manually add the longest lead arrow using Inkscape: width=1.9
#
# Put back the text that Fritzing svg export dropped off the schematic
sed '
s^>Transistor</text>^>Transistor<tspan font-size="3.9" x="10" y="17">Collector</tspan><tspan font-size="3.9" x="37" y="9">Base</tspan><tspan font-size="3.9" x="44" y="17">Emitter</tspan></text>^
s^>gnd</text>^>gnd<tspan font-size="4" x="0" y="9.25">(ground) (-)</tspan></text>^
s^>resistor</text>^>resistor<tspan font-size="5.5" x="2" y="-14">Arduino</tspan></text>^
' raw/CIRC03_schem.svg >raw/CIRC03_schem-fix.svg
# This does not fix the inverted text, so need to do that manually:
# Manually (text editor) remove the x,y coordinates for the Pin «n» text. and the
# matrix entry for the containing group, then use Inkscape to reposition the text
# Also need to fix the "M"otor entry: find ">M<" then change the wrapping matrix
# transfrom from "1, 0, 0, 1" to "1, 0, 0, -1", and reduce the y offset by 3.0
# CIRC-04
# Put back the text that Fritzing svg export dropped off the schematic
sed '
s^>gnd</text>^>gnd<tspan font-size="4" x="-14" y="9.25">(ground) (-)</tspan></text>^
s^>Mini Servo</text>^>Mini Servo<tspan font-size="3.5" x="36" y="8">+5v</tspan><tspan font-size="3.5" x="36" y="11.8">(red)</tspan><tspan font-size="3.5" x="64" y="19.4">signal</tspan><tspan font-size="3.5" x="36" y="24.3">(white, yellow or orange)</tspan><tspan font-size="3.5" x="36" y="31.6">gnd</tspan><tspan font-size="3.5" x="36" y="35.9">(black or brown)</tspan><tspan font-size="5.5" x="62" y="1">Arduino</tspan></text>^
# ' raw/CIRC04_schem.svg >raw/CIRC04_schem-fix.svg
# This does not fix the offset "pin 9" text, so need to do that manually with inkscape
# CIRC-05
cp raw/CIRC05_bb.svg raw/CIRC05_bb-fix.svg
# manually bring the IC pin labels to the front using Inkscape
#
# Put back the text that Fritzing svg export dropped off the schematic
sed '
s^>gnd</text>^>gnd<tspan font-size="4" x="-14" y="8.5">(ground) (-)</tspan></text>^
s^>LED1</text>^>LED<tspan font-size="4" x="-4.5" y="26">resistor</tspan><tspan font-size="4" x="-8.5" y="30">(560ohm)</tspan></text>^
' raw/CIRC05_schem.svg >raw/CIRC05_schem-fix.svg
# This does not fix the offset "pin «n»" text, so do that manually with inkscape
# CIRC-06
# Put back the text that Fritzing svg export dropped off the schematic
sed '
s^>gnd</text>^>gnd<tspan font-size="4" x="0" y="8.9">(ground) (-)</tspan></text>^
s^>Piezo</text>^>Piezo<tspan font-size="4" x="0" y="8.5">Element</tspan><tspan font-size="6" x="-18.5" y="-26">Arduino</tspan></text>^
' raw/CIRC06_schem.svg >raw/CIRC06_schem-fix.svg
# This does not fix the offset "pin «n»" text, so do that manually with inkscape
# CIRC-07
cp raw/CIRC07_bb.svg raw/CIRC07_bb-fix.svg
# manually add the "longer lead" arrow using Inkscape
#
# Put back the text that Fritzing svg export dropped off the schematic
sed '
s^>gnd</text>^>gnd<tspan font-size="4" x="0" y="8.9">(ground) (-)</tspan></text>^
s^>LED</text>^>LED<tspan font-size="6" x="-12.8" y="-18.4">Arduino</tspan><tspan font-size="6" x="35" y="-25">Arduino</tspan></text>^
' raw/CIRC07_schem.svg >raw/CIRC07_schem-fix.svg
# This does not fix the offset "pin «n»" text, so do that manually with inkscape
# CIRC-08
cp raw/CIRC08_bb.svg raw/CIRC08_bb-fix.svg
# manually add the "longer lead" arrow using Inkscape
#
# Put back the text that Fritzing svg export dropped off the schematic
sed '
s^>gnd</text>^>gnd<tspan font-size="4" x="0" y="8.9">(ground) (-)</tspan></text>^
s^>resistor</text>^>resistor<tspan font-size="4" x="0" y="13">(blue-green</tspan><tspan font-size="4" x="0" y="17.5">-brown)</tspan></text>^
s^>LED</text>^>LED<tspan font-size="4" x="0" y="8.5">(light</tspan><tspan font-size="4" x="0" y="13">emitting</tspan><tspan font-size="4" x="0" y="17.5">diode)</tspan><tspan font-size="6" x="-7.2" y="-17.8">Arduino</tspan><tspan font-size="6" x="46.5" y="-7.3">Arduino</tspan><tspan font-size="4" x="51.2" y="-3.2">analog</tspan></text>^
' raw/CIRC08_schem.svg >raw/CIRC08_schem-fix.svg
# This does not fix the offset "pin «n»" text, so do that manually with inkscape
# CIRC09
cp raw/CIRC09_bb.svg raw/CIRC09_bb-fix.svg
# manually add the "longer lead" arrow using Inkscape
#
# Put back the text that Fritzing svg export dropped off the schematic
sed '
s^>gnd</text>^>gnd<tspan font-size="4" x="0" y="8.9">(ground) (-)</tspan></text>^
s^>photo</text>^>photo<tspan font-size="5.3" x="0" y="9.1">resistor</tspan><tspan font-size="4.5" x="-45.4" y="-25">Arduino</tspan><tspan font-size="4" x="-2.4" y="20.5">Arduino</tspan><tspan font-size="4" x="-1.4" y="25.1">analog</tspan></text>^
' raw/CIRC09_schem.svg >raw/CIRC09_schem-fix.svg
# This does not fix the offset "pin «n»" text, so do that manually with inkscape
# CIRC10
cp raw/CIRC10_bb.svg raw/CIRC10_bb-fix.svg
# manually remove the connector«n»leg line elements
#
# Put back the text that Fritzing svg export dropped off the schematic
# text-anchor="middle" for TMP36
sed '
s^>gnd</text>^>gnd<tspan font-size="4" x="0" y="8.9">(ground) (-)</tspan></text>^
s^>TMP36</text>^>TMP36<tspan font-size="4.5" x="53" y="5">Arduino</tspan><tspan font-size="4" x="53" y="9.5">analog</tspan><tspan font-size="4" x="23" y="-10.5">(precision</tspan><tspan font-size="4" x="23" y="-6.0">temperature</tspan><tspan font-size="4" x="23" y="-1.5">sensor)</tspan></text>^
' raw/CIRC10_schem.svg >raw/CIRC10_schem-fix.svg
# This does not fix the offset "pin «n»" text, so do that manually with inkscape
# CIRC11
# Put back the text that Fritzing svg export dropped off the schematic
sed '
s^>Diode</text>^>Diode<tspan font-size="4" x="0" y="8.9">(flyback)</tspan></text>^
s^>Transistor</text>^>Transistor<tspan font-size="3.9" x="2" y="-3">Collector</tspan><tspan font-size="3.9" x="-22" y="9">Base</tspan><tspan font-size="3.9" x="2" y="16">Emitter</tspan></text>^
' raw/CIRC11_schem.svg >raw/CIRC11_schem-fix.svg
# This does not fix mirrored text: "N.C.", "C" and "N.O." text elements amd following pin number text labels.
# This does not fix the offset "pin «n»" text, so do that manually with inkscape, or add 3.0 to the (first) "pin 2" text element x coordinate
sed '
s^>Diode</text>^>Diode<tspan font-size="4" x="0" y="8.9">(flyback)</tspan></text>^
s^>Transistor</text>^>Transistor<tspan font-size="3.9" x="2" y="-3">Collector</tspan><tspan font-size="3.9" x="-22" y="9">Base</tspan><tspan font-size="3.9" x="2" y="16">Emitter</tspan></text>^
' raw/CIRC11h_schem.svg >raw/CIRC11h_schem-fix.svg
# This does not fix mirrored text: For the 2 instances of "N.C.</text>", matrix x 0 0 1 ==> x 0 0 -1 and subtract one from the y offset for each of the block of text groups, including the connection pin label text just after that.
# This does not fix the offset "pin «n»" text, so do that manually with inkscape, or add 3.0 to the (first) "pin 2" text element x coordinate
sed '
s^>Diode</text>^>Diode<tspan font-size="4" x="0" y="8.9">(flyback)</tspan></text>^
s^>Transistor</text>^>Transistor<tspan font-size="3.9" x="2" y="-3">Collector</tspan><tspan font-size="3.9" x="-22" y="9">Base</tspan><tspan font-size="3.9" x="2" y="16">Emitter</tspan></text>^
' raw/CIRC11hc_schem.svg >raw/CIRC11hc_schem-fix.svg
# This does not fix mirrored text: "N.C.", "N.O.", "C", and pin number labels for the relay switch contacts.
# * matrix -1 0 0 1 ==> 1 0 0 1 and text-anchor="end" ==> text-anchor="start"
# * matrix 1 0 0 1 ==> -1 0 0 1 and text-anchor="start" ==> text-anchor="end"
# lots of graphic elements that have been converted to "g" elements that can be deleted.
Rotate the "M" in the motor 90 degrees counter-clockwise: matrix 1 0 0 1 ==> 0 -1 -1 0 and adjust postion: x+=3.4, y-=3.4
For motor pin number 1 and 2, matrix 1 0 0 1 ==> 0 -1 1 - and (only) x+=1.6
# CIRC12
cp raw/CIRC12_bb.svg raw/CIRC12_bb-fix.svg
# manually add the "longer lead" arrow using Inkscape
# Put back the text that Fritzing svg export dropped off the schematic
sed '
s^>RGB LED</text>^>RGB LED<tspan font-size="5" x="0" y="-7.5">common</tspan><tspan font-size="5" x="1" y="-2">cathode</tspan><tspan font-size="4" x="25" y="9.5">longest</tspan><tspan font-size="4" x="30.7" y="14">lead</tspan></text>^
' raw/CIRC12_schem.svg >raw/CIRC12c_schem-fix.svg
# This does not fix the inverted text, so need to do that manually:
# Manually (text editor) remove the x,y coordinates for the Pin «n» text. and the
# matrix entry for the containing group, then use Inkscape to reposition the text.
# Need to move "Pin 9" separate from the others.
# Put back the text that Fritzing svg export dropped off the schematic
sed '
s^>RGB LED</text>^>RGB LED<tspan font-size="5" x="0" y="-7.5">common</tspan><tspan font-size="5" x="0" y="-2">anode</tspan><tspan font-size="4" x="25" y="-18.5">longest</tspan><tspan font-size="4" x="30.7" y="-14">lead</tspan></text>^
' raw/CIRC12a_schem.svg >raw/CIRC12a_schem-fix.svg
# This does not fix the inverted text, so need to do that manually:
# Manually (text editor) remove the x,y coordinates for the Pin «n» text. and the
# matrix entry for the containing group, then use Inkscape to reposition the text.
# Need to move "Pin 9" separate from the others.
# CIRC15
# nothing to doe
# sed '
# ' raw/CIRC15_schem.svg >raw/CIRC15_schem-fix.svg
#