% (find-sfcfile "zhas.tex")
% (find-sfcfile "zhas.lua")
% (defun c () (interactive) (find-sh "lualatex zhas.tex"))
% (defun d () (interactive) (find-xpdfpage    "zhas.pdf"))
% (find-xpdfpage "zhas.pdf")
\documentclass[oneside]{book}
\usepackage[latin1]{inputenc}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{tikz}
\usepackage{luacode}
\begin{document}

\tikzset{outer/.style=gray,very thin}
\tikzset{cut/.style=very thick}

\def\bsk{\bigskip}
\def\msk{\medskip}
\def\ssk{\smallskip}

% (find-dn4ex "edrx08.sty" "colors")
\definecolor{orange}{rgb}{1,.64,0}
\def\blue  #1{{\color{blue}#1}}
\def\red   #1{{\color{red}#1}}
\def\orange#1{{\color{orange}#1}}
\def\yellow#1{{\color{yellow}#1}}
\def\smashedvrule#1#2#3{\vrule width#1 height#2 depth#3 \kern-#1}
\def\bicolorhbox#1{{%
  \setbox0\hbox{#1}%
  \yellow{\smashedvrule{\wd0}{\ht0}{0pt}}%
  \orange{\smashedvrule{\wd0}{0pt}{\dp0}}%
  \box0%
  }}

% (find-dn4ex "edrx08.sty" "dags")
\newdimen\mypictureunit
\setbox0=\hbox{\rm0}
\mypictureunit=.085\wd0
\mypictureunit=.084\wd0
%
\def\dagput(#1,#2)#3{\put(#1,#2){\hbox to 0pt{\hss\scriptsize#3\hss}}}
\def\dagpicture(#1,#2)(#3,#4)[#5]#6{{%
  %\unitlength=.1ex%
  %\setbox0\hbox{x}\unitlength=.1\wd0%
  %\setbox0\hbox{x}\unitlength=.095\wd0%
  %\setbox0\hbox{x}\unitlength=.090\wd0%
  \unitlength=\mypictureunit
  \lower #5\unitlength\hbox{%
    \begin{picture}(#1,#2)(#3,#4)
      #6
    \end{picture}%
  }}}

\def\bdagpicture(#1,#2)(#3,#4)[#5]#6{{%
  \bicolorhbox{\dagpicture(#1,#2)(#3,#4)[#5]{#6}}%
}}

\def\dagHouse#1#2#3#4#5{%
  \bdagpicture(20,36)(-10,-24)[12]{
    \dagput( 0,  0){$#1$}    % top
    \dagput(-6,-12){$#2$}    % second line, left
    \dagput( 6,-12){$#3$}    % second line, right
    \dagput(-6,-24){$#4$}    % third line, left
    \dagput( 6,-24){$#5$}    % third line, right
  }}

\def\dagFoo#1#2#3#4#5{%
  \dagpicture(20,36)(-10,-24)[12]{
    \dagput( 0,  0){$#1$}    % top
    \dagput(-6,-12){$#2$}    % second line, left
    \dagput( 6,-12){$#3$}    % second line, right
    \dagput(-6,-24){$#4$}    % third line, left
    \dagput( 6,-24){$#5$}    % third line, right
  }}

$\dagHouse abcde$

1: $\bdagpicture(12,12)(12,12)[0]{\dagput(0, 0){a}}$

2: $\bdagpicture(12,12)(12,0)[0]{\dagput(0, 0){a}}$

3: $\bdagpicture(12,12)(0,0)[0]{\dagput(0, 0){a}}$

4: $\bdagpicture(12,12)(-6,0)[0]{\dagput(0, 0){a}}$

5: $\bdagpicture(12,12)(-6,0)[0]{\dagput(0, 0){a} \dagput(12, 0){b} \dagput(6, 6){c}}$

6: $\bdagpicture(12,12)(-6,0)[0]{\dagput(0, 0){1} \dagput(14, 0){2} \dagput(7, 7){3}}$

7: $\bdagpicture(26,18)(-7,0)[0]{\dagput(0, 0){1} \dagput(14, 0){2} \dagput(7, 7){3}}$

8: $\bdagpicture(26,18)(-6,0)[0]{\dagput(0, 0){1} \dagput(14, 0){2} \dagput(7, 7){3}}$

9: $\bdagpicture(19,18)(-6,0)[0]{\dagput(0, 0){1} \dagput(14, 0){2} \dagput(7, 7){3}}$

a: $\bdagpicture(19,18)(-6,0)[6]{\dagput(0, 0){1} \dagput(14, 0){2} \dagput(7, 7){3}}$






% (find-es "tikz" "luacode")
% (find-es "luatex" "luacode")

\begin{luacode*}
dagpictureheader0 = function (maxx, maxy, lower)
    local sh = 7*maxx + 12
    local sv = 7*maxy + 12
    local dh = -6
    local dv = 0
    local lv = (lower or 0)* 7
    return format("(%d,%d)(%d,%d)[%3.1f]", sh, sv, dh, dv, lv)
  end
bdagpictureheader = function (maxx, maxy, lower)
    return "\\bdagpicture"..dagpictureheader0(maxx, maxy, lower)
  end
dc = function (x, y)
    local h = 7*x
    local v = 7*y
    return format("(%d,%d)", h, v)
  end
dagputheader = function (x, y)
    return format("\\dagput(%d,%d)", 7*x, 7*y)
  end
\end{luacode*}

% (find-es "luatex" "LUA_INIT")
% (find-angg "sheavesforchildren/zhas.lua")
\directlua{
  dofile(os.getenv("LUA_INIT"):sub(2))
  dofile "zhas.lua"
}

\def\luaexpr#1{\directlua{tex.print(#1)}}
\def\uv(#1,#2){\luaexpr {pcomma(xyfromuv(#1, #2))}}

Hello

bdagpicture\luaexpr{dagpictureheader0(2,3)}

dagput\luaexpr{dc(1,3)} 1

dagput\luaexpr{dc(0,2)} 2

dagput\luaexpr{dc(2,2)} 3

dagput\luaexpr{dc(1,1)} 4

dagput\luaexpr{dc(0,0)} 5

$
\bdagpicture(26,33)(-6,0)[0.0]{
}
$

% $
% \expandafter\bdagpicture\luaexpr{dagpictureheader0(2,3)}{
%   \dagput\luaexpr{dc(1,3)}{1}
%   \dagput\luaexpr{dc(0,2)}{2}
%   \dagput\luaexpr{dc(2,2)}{3}
%   \dagput\luaexpr{dc(1,1)}{4}
%   \dagput\luaexpr{dc(0,0)}{5}
% }
% $

\catcode`=13 \def{\ensuremath{\bullet}}

a%
$
\luaexpr{bdagpictureheader(2,3,1)}{
  \luaexpr{dagputheader(1,3)}{1}
  \luaexpr{dagputheader(0,2)}{2}
  \luaexpr{dagputheader(2,2)}{3}
  \luaexpr{dagputheader(1,1)}{4}
  \luaexpr{dagputheader(0,0)}{5}
}
$%
b

%   \dagput\luaexpr{dc(1,3)}{1}
%   \dagput\luaexpr{dc(0,2)}{2}
%   \dagput\luaexpr{dc(2,2)}{3}
%   \dagput\luaexpr{dc(1,1)}{4}
%   \dagput\luaexpr{dc(0,0)}{5}
% }
% $

\end{document}




-- (find-dn4ex "edrx08.sty" "dags")

 (eepitch-lua51)
 (eepitch-kill)
 (eepitch-lua51)
dagpictureheader0 = function (maxx, maxy, lower)
    local sh = 7*maxx + 12
    local sv = 7*maxy + 12
    local dh = -6
    local dv = 0
    local lv = (lower or 0)* 7
    return format("(%d,%d)(%d,%d)[%3.1f]", sh, sv, dh, dv, lv)
  end

= dagpictureheader0(0, 0)
= dagpictureheader0(1, 0)
= dagpictureheader0(1, 1)




% Local Variables:
% coding:           raw-text-unix
% ee-anchor-format: "«%s»"
% End:

