jw_cad 外部変形 - (1303) luaで指示点を確認する(hp) -

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

 

luaで指示点を確認する(hp)

:luaで指示点を確認する(hp)
@echo off
for /f "delims=:" %%n in ('findstr /n "^#!" %0') do (
  copy jwc_temp.txt myfiles > nul
  more +%%n %0 | lua - myfiles > jwc_temp.txt
)
goto:eof

REM #jww
REM #1-%d 点を指示してください
REM #99#
REM #zs
REM #e

#!この次の行からプログラムを書いてください
hs = {}; hp = {}; lg = ""
for line in io.lines(arg[1]) do
  F = {}
  line:gsub("%S+", function (x) table.insert(F, x) end)
  if line:match("^hs") then
    for i = 0, 15 do
      hs[("%x"):format(i)] = F[i+2]*1
    end
  end
  if line:match("^hzs") then
    w, h = F[2]*1, F[3]*1
  end
  if line:match("^hp([1-9][0-9]?)") then
    hp[line:match("^hp([1-9][0-9]?)")*1] = {F[2]*1, F[3]*1}
  end
  if line:match("^lg[0-9a-f]") then
    plg = line:sub(3,3); if lg == "" then lg = plg end
  end
end

sc = hs[lg]
w = w * sc
h = h * sc
print( ("%s %s %s %s"):format(-w / 2, 0, w / 2, 0))
print( ("%s %s %s %s"):format(0, -h / 2, 0, h / 2))
print("ch 0 0 1 0 \"[0, 0]")
hpn = #hp
for i = 1, hpn do
  x, y = unpack(hp[i])
  print( ("pt %s %s"):format(x, y))
  print( ("ch %s %s 1 0 \"[%s, %s]"):format(x, y, x, y))
end