[NTG-context] new upload

Hans Hagen j.hagen at xs4all.nl
Tue Apr 19 20:23:53 CEST 2022


Hi,

I uploaded a new lmtx. Some more adaptive magic ... I'm not sure how 
usefull it is but users always find ways to apply such things. I 
attached a test file.

Hans

-----------------------------------------------------------------
                                           Hans Hagen | PRAGMA ADE
               Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
        tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl
-----------------------------------------------------------------
-------------- next part --------------
\starttext

\setupexternalfigures
  [location={default,global}]

\startMPdefinitions
    def TickTock =
        interim linecap := squared;
        save p ; path p ; p := fullsquare xysized(AdaptiveWidth,.9(AdaptiveHeight+AdaptiveDepth)) ;
        fill p withcolor AdaptiveColor ;
        draw bottomboundary (p enlarged (-AdaptiveThickness) )
            withdashes (3*AdaptiveThickness)
            withpen pencircle scaled AdaptiveThickness
            withcolor white ;
    enddef ;
\stopMPdefinitions

\startsetups adaptive:test
    \setbox\usedadaptivebox\hbox to \usedadaptivewidth yoffset -.9\usedadaptivedepth \bgroup
        \hss
        \startMPcode
            TickTock ;
        \stopMPcode
        \hss
   \egroup
\stopsetups

\definecolor[adaptive:tick][.25(blue,green)]
\definecolor[adaptive:tock][.75(blue,green)]

\defineadaptive
  [tick]
  [setups=adaptive:test,
   color=adaptive:tick,
   foregroundcolor=white,
   foregroundstyle=\infofont,
   strut=yes]

\defineadaptive
  [tock]
  [tick]
  [color=adaptive:tock]

\dorecurse{5}{
    \dostepwiserecurse{1}{150}{1}{%
        this~#1.##1 is~#1.##1 test~#1.##1
        \ifodd##1\relax
            \adaptivebox[tick]{\hss tick #1.##1\hss}
        \else
            \adaptivebox[tock]{\hss tock #1.##1\hss}
        \fi
    }
    \blank
}

\startsetups adaptive:test
    \setbox\usedadaptivebox\hbox to \usedadaptivewidth yoffset -\usedadaptivedepth \bgroup
        \externalfigure
          [cow.pdf]
          [width=\usedadaptivewidth,
           height=\dimexpr\usedadaptiveheight+\usedadaptivedepth\relax]%
   \egroup
\stopsetups

\dorecurse{5}{
    \dostepwiserecurse{1}{150}{1}{%
        this~#1.##1 is~#1.##1 test~#1.##1
        {\adaptivebox[strut=yes,setups=adaptive:test]{}}
    }
    \blank
}

\page

\startsetups adaptive:test
    \setbox\usedadaptivebox\vbox to \usedadaptivetotal \bgroup
        \externalfigure
          [cow.pdf]
          [width=\usedadaptivewidth,
           height=\usedadaptivetotal]%
   \egroup
\stopsetups

\ruledvbox to \textheight {
    \par \begstrut \samplefile{tufte} \endstrut \par
    \adaptivevbox[strut=yes,setups=adaptive:test]{\hsize\textwidth\hss}
    \par \begstrut \samplefile{tufte} \endstrut
}

\page

\startsetups adaptive:test:a
    \setbox\usedadaptivebox\vbox to \usedadaptivetotal \bgroup
        \externalfigure
          [cow.pdf]
          [width=\framedmaxwidth,
           frame=on,
           height=\usedadaptivetotal]%
   \egroup
\stopsetups

\startsetups adaptive:test:b
    \setbox\usedadaptivebox\vbox to \usedadaptivetotal \bgroup
        \externalfigure
          [cow.pdf]
          [width=\usedadaptivewidth,
           frame=on,
           height=\usedadaptivetotal]%
   \egroup
\stopsetups

\showframe

\framed[height=18cm,align=middle,adaptive=yes,top=,bottom=] {%
    \begstrut \samplefile{tufte} \endstrut
    \par
    \adaptivevbox
      [strut=yes,setups=adaptive:test:a]
      {\showstruts\strut\hsize5cm\hss}%
    \par
    \adaptivevbox
      [strut=yes,setups=adaptive:test:b]
      {\showstruts\strut\hsize5cm\hss}%
    \par
    \begstrut \samplefile{tufte} \endstrut
}

\stoptext


More information about the ntg-context mailing list