[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
gEDA-user: sym/sch scaler
Quickie perl script to scale a symbol or schematic. Lightly tested,
probably not as robust as it could be, tossed out in case anyone needs
it. Me, I need to scale a title-C to 40% or so bigger (no, a title-D
is a different aspect ratio, a problem you don't have with metric page
sizes).
#!/usr/bin/perl
# -*- perl -*-
# Copyright 2006 DJ Delorie, licenced under GPL v2
$scale = shift;
exit 1 if $scale <= 0;
@syntax = ("L 1 1 1 1 0 1 0 0 1 1",
"G 1 1 1 1 0 0 0 0",
"B 1 1 1 1 0 1 0 0 1 1 0 1 0 1 0 1",
"V 1 1 1 0 1 0 0 1 1 0 1 0 1 0 1",
"A 1 1 1 0 0 0 1 0 0 1 1",
"T 1 1 0 1 0 0 0 0 0",
"N 1 1 1 1 0",
"U 1 1 1 1 0 0",
"P 1 1 1 1 0 0 0",
"C 1 1 0 0 0 0",
"F 0 1 0",
);
for $s (@syntax) {
($type, @args) = split(' ', $s);
for ($a=0; $a<@args; $a++) {
$syntax{$type}[$a] = $args[$a];
}
}
@in = <>;
for ($i=0; $i<@in; $i++) {
$in[$i] =~ s/[\r\n]+$//;
($type, @args) = split(' ', $in[$i]);
if ($syntax{$type}) {
for ($a=0; $a<@args; $a++) {
if ($syntax{$type}[$a]) {
$args[$a] = int($args[$a] * $scale);
}
}
print join(' ', $type, @args), "\n";
} else {
print $in[$i], "\n";
}
if ($type eq "T") {
$text = $args[8];
for ($t=0; $t<$text; $t++) {
$i ++;
print $in[$i];
}
}
}