[NTG-context] new upload

Hans Hagen j.hagen at xs4all.nl
Fri Apr 15 20:24:07 CEST 2022


Hi,

I uploaded a new lmtx. Apart from a experimental intersection feature in 
the mp library (and metafun, more will be revealed when MS an I are okay 
with it) there is not that much news.

I decided to turn some test code into a mechanism which is illustrated 
below. Adaptive boxes are hboxes that act a bit like glue which means 
that when we hook in e.g. a graphic it can be made to adapt.

We can add some more methods if needed so maybe you see other usage. The 
interface is rather lightweight and the overhead is quite resonable.

Hans


===================

\starttext

\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]

% with postprocessing

\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
}

\page

% without postprocessing

\dorecurse{5}{
     \dostepwiserecurse{1}{150}{1}{%
         this~#1.##1 is~#1.##1 test~#1.##1
         {\showboxes\adaptivebox[strut=yes,foregroundcolor=darkred]{\hss 
test #1.##1\hss}}
     }
     \blank
}

\page

% with images

% a weird one

\setupexternalfigures
   [location={default,global}]

\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
}

\stoptext

It actually uses an already present for a while low level engine feature 
that we introduced as part of the math processing update:

\dorecurse
   {1000}
   {test \uleaders\ruledhbox{\hss#1\hss}\hskip2em minus 1em\ }


Next on the todo is to move some experimental graphic trickery related 
to math (matrices) into the core but the interfacing needs some thought.

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
-----------------------------------------------------------------


More information about the ntg-context mailing list