jw_cad 外部変形 - (514) luaで円を描く -

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

 

luaで円を描く

:luaで円を描く
@echo off
for /f "delims=:" %%n in ('findstr /n "^#!" %0') do (
  copy jwc_temp.txt myfiles > nul
  more +%%n %0 | lua > jwc_temp.txt
)
goto:eof

REM #jww
REM #1-%d 円の中心を指示してください
REM #2%d 円周上の点を指示してください
REM #e

#!この次の行からプログラムを書いてください
for line in io.lines("myfiles") do
  F = {}
  string.gsub(line, "%S+", function (x) table.insert(F, x) end)
  if string.match(line, "^hp1") then x1, y1 = F[2], F[3] end
  if string.match(line, "^hp2") then x2, y2 = F[2], F[3] end
end
print("ci", x1, y1, math.sqrt( (x2 - x1) ^ 2 + (y2 - y1) ^ 2) )