jw_cad 外部変形 - (1290) luaで罫線を引く -

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

 

luaで罫線を引く

:luaで罫線を引く
@echo off
set yp=8
set div=2
set sx=15
set sy=20
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 #hp
REM #zs
REM #e

#!この次の行からプログラムを書いてください
function int(a) return a < 0 and math.ceil(a) or math.floor(a) end

yp = os.getenv('yp')*1
div = os.getenv('div')*1
sx = os.getenv('sx')*1
sy = os.getenv('sy')*1
for line in io.lines("myfiles") do
  F = {}
  string.gsub(line, "%S+", function (x) table.insert(F, x) end)
  if line:match("^hzs") then
    w, h = F[2]*1, F[3]*1
    n = int( (h - 2 * sy) / yp)
    x0 = sx
    x1 = x0 + w / div - sx
    print("bz")
    print("lc9")
    print("lt9")
    for i = 0, n - 1 do
      y = yp * i + sy
      print(string.format("%s %s %s %s", x0, y, x1, y))
    end
  end
end