外部変形は データのやり取りをテキストファイルで行うので プログラム言語は 自由に選ぶことができます。図形は機能的かつシンプルなため、数多くのユーザーに受け入れられています。
vbscriptでソリッド図形の円環を描く
:vbscriptでソリッド図形の円環を描く
@echo off
set c=%*
if defined c call:set %c%
if exist %~dpn0.txt (
for /f "tokens=*" %%a in (%~dpn0.txt) do call:set %%a
)
if not defined w set w=1
if not defined r2 set r2=0.5
if defined c (
echo %w% %r2% > %~dpn0.txt
)
if not exist %~dp0eval.vbs echo ExecuteGlobal WScript.StdIn.ReadAll > %~dp0eval.vbs
for /f "delims=:" %%n in ('findstr /n "^#!" %0') do (
copy jwc_temp.txt myfiles > nul
(
: echo Option Explicit
echo On Error Resume Next
: echo On Error GoTo 0
more +%%n %0
) | cscript //nologo %~dp0eval.vbs > jwc_temp.txt
)
goto:eof
REM #jww
REM #1-%d 中心点を指示してください
REM #2%d 円周上の点を指示してください
REM #c 扁平率(0.1~10.0) w, 内円半径比 r2/r =
REM #e
:set
if not defined w set w=%1
if not defined r2 set r2=%2
goto:eof
#!この次の行からプログラムを書いてください
'1)正規表現
Dim re
Set re = New RegExp
re.IgnoreCase = True '大文字と小文字を区別しない
re.Global = True '文字列全体を検索する
function reSplit(str)
re.Pattern = "[ ]+"
reSplit = Split(Trim(re.Replace(str," ")))
end function
function reTest(pat, str)
re.Pattern = pat
reTest = re.Test(str)
end function
'2)円周率
Const PI = 3.141592653589793
'3)環境変数
Dim Env
Set Env = CreateObject("WScript.Shell").Environment("Process")
'4)ユーザ定義関数
function rgb(r, g, b)
rgb = r + g * 256 + b * 256 * 256
end function
function hypot(x, y)
hypot = sqr(x * x + y * y)
end function
function ptdist(x, y)
if typename(x) = "Integer" then
ptdist = hypot(y(0), y(1))
exit function
end if
if typename(y) = "Integer" then
ptdist = hypot(x(0), x(1))
exit function
end if
if typename(x) = "String" then x = Split(Trim(x))
if typename(y) = "String" then y = Split(Trim(y))
ptdist = hypot(y(0) - x(0), y(1) - x(1))
end function
Dim line, F
Dim p1, p2, hk, w, d, r, r2
With CreateObject("Scripting.FileSystemObject")
With .OpenTextFile("myfiles")
Do While Not .AtEndOfStream
line = .ReadLine: F = reSplit(line)
if reTest("^hk",line) then hk = F(1)
if reTest("^hp1",line) then p1 = Array(F(1),F(2))
if reTest("^hp2",line) then p2 = Array(F(1),F(2))
Loop
End With
End With
w = CDbl(Env("w"))
r2 = CDbl(Env("r2"))
d = hk * PI / 180
r = ptdist(p1, p2)
With WScript
.Echo "lc10 " & rgb(0, 128, 128)
.Echo "so " & Join(p1) & " " & Join(Array(r, w, d, 0, PI * 2, r * r2))
End With