電子工作記事も書くようになり、ブレッドボードの絵を使うことが増えてきましたが、未だ絵は手描きです(libreoffice)。手描きはとても面倒です。ネットで良く見かけるブレッドボードの絵って何か特別なツール使ってるのでしょうけど、それを調べることすら面倒なので、次回からコマンドラインで作れるように、SVG絵画してみます。
まずは、30 x 10=300個の穴から。
~$ bread.sh
1 a=`perl -e '
2 foreach $n (0..299){
3 $x = int($n / 30) * 20 + 85;
4 $y = int($n % 30) * 20 + 25;
5 print qq#<rect x="$x" y="$y" width="9" height="9" fill="glay"></rect>#;
6 }
7 '`
8
9 cat <<EOL > /tmp/tmp.svg
10 <svg width="384" height="650">
11 <rect x="0" y="0" width="384" height="650" fill="white"></rect>
12 $a
13 </svg>
14 EOL
15 inkscape -z -e out.png /tmp/tmp.svg

左右5列ずつで分かれているので、3行目を以下のように修正します。
3 $x = int($n / 30) * 20 + 85 + ($n >= 150)*25;

電源ラインの穴も作ります。
7 foreach $n (0..99){
8 $x = int($n / 25) * 20 + 15 + ($n >= 50)*285;
9 $y = int($n % 25) * 20 + 30 + int(($n % 25) /5) * 20;
10 print qq#<rect x="$x" y="$y" width="9" height="9" fill="glay"></
11 }

まあこれで十分な気もしますが、さらにいろいろ飾り付けます。
~$ cat -n bread.sh
1 a=`perl -e '
2 foreach(split / /, "0,60 62,125 197,125 324,60"){
3 my($x,$w) = split /,/,$_;
4 print qq#<rect x="$x" y="0" width="$w" height="650" stroke="black" fill="none"></rect>#;
5 }
6 foreach(split / /, "8:red 50:blue 334:red 376:blue"){
7 my($x,$c) = split /:/,$_;
8 print qq#<line x1="$x" y1="20" x2="$x" y2="620" stroke="$c" stroke-width="2"/>#;
9 }
10 foreach $n (0..99){
11 $x = int($n / 25) * 20 + 15 + ($n >= 50)*285;
12 $y = int($n % 25) * 20 + 30 + int(($n % 25) /5) * 20;
13 print qq#<rect x="$x" y="$y" width="9" height="9" fill="glay"></rect>#;
14 }
15 foreach $n (0..59){
16 $num=($n%30)+1;
17 $x = int($n / 30) * 20 + 75 + ($n >= 30)*215;
18 $y = int($n % 30) * 20 + 35;
19 print qq#<text x="$x" y="$y" font-size="15" text-anchor="middle">$num</text>#;
20 }
21 $x=90;
22 foreach $ch (split //,"abcdefghij"){
23 print qq#<text x="$x" y="15" font-size="15" text-anchor="middle">$ch</text>#;
24 print qq#<text x="$x" y="635" font-size="15" text-anchor="middle">$ch</text>#;
25 $x += 20;
26 $x += 25 if($ch eq "e");
27 }
28 foreach $n (0..299){
29 $x = int($n / 30) * 20 + 85 + ($n >= 150)*25;
30 $y = int($n % 30) * 20 + 25;
31 print qq#<rect x="$x" y="$y" width="9" height="9" fill="glay"></rect>#;
32 }
33 '`
34
35 cat <<EOL > /tmp/tmp.svg
36 <svg width="384" height="650">
37 <rect x="0" y="0" width="384" height="650" fill="white"></rect>
38 $a
39 </svg>
40 EOL
41 inkscape -z -e out.png /tmp/tmp.svg

後は、これに部品が載せられるようにすれば良いですね。



コメント