jw_cad 外部変形 - (673) パワーシェルでソリッド図形の円を描く -

外部変形は データのやり取りをテキストファイルで行うので プログラム言語は 自由に選ぶことができます。図形は機能的かつシンプルなため、数多くのユーザーに受け入れられています。

 

パワーシェルでソリッド図形の円を描く

:パワーシェルでソリッド図形の円を描く
@echo off
call %~dp0set "w" "%1" %~dpn0.txt
for /f "delims=:" %%n in ('findstr /n "^#!" %0') do (
  more +%%n %0 | powershell -command -
)
goto:eof

REM #jww
REM #1-%d 中心点を指示してください
REM #2%d 円周上の点を指示してください
REM #c 扁平率(0.1~10.0) w =
REM #e

#!ここから more +n %0 の n 行目:最初の行は 0 行
function hypot ($x,$y)
{
  [math]::sqrt($x*$x+$y*$y)
}
$w = [double] $env:w
gc jwc_temp.txt | %{
  if ($_ -match "^hk") { $hk = [double] $_.substring(3) }
  if ($_ -match "^hp1-") { $p1 = [regex]::split($_,' +')[1,2] }
  if ($_ -match "^hp2")  { $p2 = [regex]::split($_,' +')[1,2] }
}
&{
  $x1,$y1,$x2,$y2 = $($p1+$p2 | %{ [double] $_ })
  $r,$g,$b = 0,128,128
  "lc10 $($r+$g*256+$b*256*256)"
  $r = hypot ($x2-$x1) ($y2-$y1)
  "sc $p1 $r $w $($hk*[math]::pi/180) 0 $([math]::pi*2) 100"
} | sc jwc_temp.txt

#ここまで powershell は 文末に必ず空白行を置いてください