[NTG-context] offset for background overlay

Hans Hagen j.hagen at xs4all.nl
Sat Apr 11 19:41:17 CEST 2020


On 4/11/2020 4:15 PM, mf wrote:
> Hello list,
> this MWE is a simplified version of a real case:
> 
> \startuseMPgraphic{cell:triangle}
>    path p ; p := unittriangle rotated 90 xscaled 2.5 OverlayWidth 
> yscaled 2.5 OverlayHeight ;
>    draw p withcolor red ;
> \stopuseMPgraphic
> \defineoverlay[triangle][{\uniqueMPgraphic{cell:triangle}}]
> \starttext
> \bTABLE[frame=off]
>    \bTR
>      \bTD[nx=2,background=triangle,align=middle] \dontleavehmode a\crlf 
> text \eTD
>    \eTR
>    \bTR[toffset=1mm]
>      \bTD left \eTD
>      \bTD right \eTD
>    \eTR
> \eTABLE
> \stoptext
here's a very ugly solution

\startuseMPgraphic{cell:triangle}
     fill llcorner OverlayBox
         -- lrcorner OverlayBox
         -- (center bottomboundary OverlayBox shifted 
(0,\MPy{foo:2}-\MPh{foo:2}+\MPd{foo:2}-\MPy{foo:1}))
         -- cycle
         withcolor red ;
     setbounds currentpicture to OverlayBox ;
\stopuseMPgraphic

\defineoverlay[triangle][{\uniqueMPgraphic{cell:triangle}}]

\starttext

\bTABLE[frame=off]
   \bTR
     \bTD[nx=2,align=middle,height=0pt,background=triangle]\xypos{foo:1}\eTD
   \eTR
   \bTR
     \bTD[nx=2,align=middle] \dontleavehmode a\crlf text \eTD
   \eTR
   \bTR[toffset=1mm]
     \bTD \hpos{foo:2}{\strut} left \eTD
     \bTD right \eTD
   \eTR
\eTABLE

\stoptext

it is probably possible to get some info otherwise (more efficient) if 
really needed (if we add some helpers)

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