@REM 矢印の大きさを変更する
@echo off
REM #jww
REM #cd
REM #c変更対象矢印の最大長さ(図寸)無指定:3:/_/a
REM #c変更後の矢印の長さ(図寸)無指定:2:/_/b
REM #h1
REM #e
copy jwc_temp.txt temp.txt > nul
ruby -Ks 矢印変換.rb temp.txt %1 %2 > jwc_temp.txt
◎スクリプトファイル(ファイル名 矢印変換.rb)
BEGIN{
print "hd\n"
$ha =3
$hb =1
while ARGV.length > 1
case argument = ARGV.pop
when /^\/a/
$ha = argument[ 2 .. -1].to_f
when /^\/b/
$hb = argument[ 2 .. -1].to_f
end
end
$by=Array.new
$x1=Array.new
$y1=Array.new
$x2=Array.new
$y2=Array.new
}
def main
while ARGF.gets
xy =split
if xy[0] =="hq"
elsif xy[0] =~ /^hs/
n=1;while (nelsif xy[0] =~ /^lg/
print $_
$lg=xy[0].delete("lg");$zusun=$by[$lg.to_i]
elsif xy[0] =~ /^[0-9]/ or xy[0] =~ /^-/
xy.collect!{|item| item.to_f}
if xy[2] < xy[0]
x = xy[2]
xy[2] = xy[0]
xy[0] = x
y = xy[3]
xy[3] = xy[1]
xy[1] = y
end
$x1.push(xy[0])
$y1.push(xy[1])
$x2.push(xy[2])
$y2.push(xy[3])
else
print $_
end
end
u=0
while (u<$x1.size)
x=$x2[u]-$x1[u]
y=$y2[u]-$y1[u]
$xy=Math.sqrt(x**2+y**2)
dx=x/$xy
dy=y/$xy
if $xy > $ha*$zusun
naname($x1[u],$y1[u],$x2[u],$y2[u])
elsif $xy <= $ha*$zusun
ax=$x1.select{|item| item==$x1[u]}
if ax.size>=2
ay=$y1.select{|item| item==$y1[u]}
if ay.size>=2
naname($x1[u],$y1[u],$x1[u]+$hb*$zusun*dx,$y1[u]+$hb*$zusun*dy)
end
end
bx=$x1.select{|item| item==$x2[u]}
if bx.size>=1
by=$y1.select{|item| item==$y2[u]}
if by.size>=1
naname($x2[u],$y2[u],$x2[u]-$hb*$zusun*dx,$y2[u]-$hb*$zusun*dy)
end
end
cx=$x2.select{|item| item==$x1[u]}
if cx.size>=1
cy=$y2.select{|item| item==$y1[u]}
if cy.size>=1
naname($x1[u],$y1[u],$x1[u]+$hb*$zusun*dx,$y1[u]+$hb*$zusun*dy)
end
end
ddx=$x2.select{|item| item==$x2[u]}
if ddx.size>=2
ddy=$y2.select{|item| item==$y2[u]}
if ddy.size>=2
naname($x2[u]-$hb*$zusun*dx,$y2[u]-$hb*$zusun*dy,$x2[u],$y2[u])
end
end
end
u+=1
end
end
def naname(x1,y1,x2,y2)
printf("%e %e %e %e\n", x1, y1, x2, y2)
end
main()