Re: [NTG-context] offset for background overlay

2020-04-13 Thread Wolfgang Schuster

mf schrieb am 13.04.2020 um 17:21:

Thanks also for the explanation of backgroundoffset: it's an offset 
relative only to the background, and it moves in the opposite direction 
of the content offset of \framed.


Looks like \framed[...,offset=VALUE,backgroundoffset=frame,...] is 
equivalent to \framed[...,offset=VALUE,backgroundoffset=-VALUE,...].


I tried to add something to the WIKI to show how it works, but the 
previews I got were not consistent with what I'm obtaining on my PC 
(with LMTX and "context --luatex"), so I gave up.


When you use "backgroundoffset=frame" you have to change the value for 
"frameoffset" to get a result because "backgroundoffset" uses now the 
"frameoffset" value.


Wolfgang
___
If your question is of interest to others as well, please add an entry to the 
Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___


Re: [NTG-context] offset for background overlay

2020-04-13 Thread mf

Or maybe a method in MP to set the bounding box of the resulting overlay?


setbounds in combination with leftenlarged, topenlarged etc.


Thanks Wolfgang, this is the kind of solution I was looking for:

\startuseMPgraphic{cell:triangle}
  path p ; p := unittriangle rotated 90 xscaled 2.5 OverlayWidth 
yscaled 2.5 OverlayHeight ;

  draw p withcolor red ;
  setbounds currentpicture to p topenlarged 6mm ;
\stopuseMPgraphic
\defineoverlay[triangle][{\uniqueMPgraphic{cell:triangle}}]
\starttext
\bTABLE[frame=off]
  \bTR
\bTD[nx=2,align=middle,background=triangle] \dontleavehmode a\crlf 
text \eTD

  \eTR
  \bTR[toffset=1mm]
\bTD left \eTD
\bTD right \eTD
  \eTR
  \bTR
\bTD another \eTD
\bTD row \eTD
  \eTR
\eTABLE
\stoptext

Thanks also for the explanation of backgroundoffset: it's an offset 
relative only to the background, and it moves in the opposite direction 
of the content offset of \framed.


Looks like \framed[...,offset=VALUE,backgroundoffset=frame,...] is 
equivalent to \framed[...,offset=VALUE,backgroundoffset=-VALUE,...].


I tried to add something to the WIKI to show how it works, but the 
previews I got were not consistent with what I'm obtaining on my PC 
(with LMTX and "context --luatex"), so I gave up.


Massi
___
If your question is of interest to others as well, please add an entry to the 
Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___


Re: [NTG-context] offset for background overlay

2020-04-11 Thread Wolfgang Schuster

mf schrieb am 11.04.2020 um 23:59:

Thanks Hans and Wolfgang.

@Wolfgang: your solution is clearer, but unfortunately it works only for 
this MWE. In the real case the triangle extends over 2 rows, but the 
table has more than 2 rows.
I tried grouping the first two rows in a 
\bTABLEbody[background=triangle], but it doesn't work.


How about nested tables:

\starttext

\bTABLE[width=1cm,height=1cm]
\bTR
\bTD A \eTD
\bTD B \eTD
\bTD C \eTD
\bTD E \eTD
\eTR
\bTR
\bTD E \eTD
\bTD[nc=2,nr=2,strut=no,align={middle,lohi}] {\bTABLE
\bTR \bTD[nc=2] X \eTD \eTR
\bTR \bTD Y \eTD \bTD Z \eTD \eTR
\eTABLE} \eTD
\bTD H \eTD
\eTR
\bTR
\bTD I \eTD
\bTD L \eTD
\eTR
\bTR
\bTD M \eTD
\bTD N \eTD
\bTD O \eTD
\bTD P \eTD
\eTR
\eTABLE

\stoptext


@both: \setupoverlay[hoffset=...,voffset=...]?
\setupframed[backgroundhoffset=...,backgroundvoffset=...] (\bTD inherits 
from \framed)?

Or maybe a method in MP to set the bounding box of the resulting overlay?


setbounds in combination with leftenlarged, topenlarged etc.


\setupframed has already a backgroundoffset option, whose value can be:

- a DIMENSION (an offset that is both horizontal and vertical)

- a "frame": what does it mean? (I looked into pack-rul.mkiv, with no 
results)


ConTeXt uses the value from the frameoffset key for backgroundoffset.

\startuseMPgraphic{frameborder}
draw OverlayBox withcolor blue ;
\stopuseMPgraphic

\defineoverlay[frameborder][\useMPgraphic{frameborder}]

\setupheader[state=high]
\setupfooter[state=high]

\starttext

\setupframed
  [width=4cm,
   height=4cm,
   offset=1cm]

\framed{}

\framed[frame=off,background=frameborder]{}

\framed[frameoffset=-5mm]{}

\framed[frameoffset=-5mm,frame=off,background=frameborder]{}

\framed[backgroundoffset=-5mm,frame=off,background=frameborder]{}

\framed[frameoffset=-5mm,backgroundoffset=frame,frame=off,background=frameborder]{}

\stoptext

Wolfgang
___
If your question is of interest to others as well, please add an entry to the 
Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___


Re: [NTG-context] offset for background overlay

2020-04-11 Thread mf

Thanks Hans and Wolfgang.

@Wolfgang: your solution is clearer, but unfortunately it works only for 
this MWE. In the real case the triangle extends over 2 rows, but the 
table has more than 2 rows.
I tried grouping the first two rows in a 
\bTABLEbody[background=triangle], but it doesn't work.


@both: \setupoverlay[hoffset=...,voffset=...]?
\setupframed[backgroundhoffset=...,backgroundvoffset=...] (\bTD inherits 
from \framed)?

Or maybe a method in MP to set the bounding box of the resulting overlay?

\setupframed has already a backgroundoffset option, whose value can be:

- a DIMENSION (an offset that is both horizontal and vertical)

- a "frame": what does it mean? (I looked into pack-rul.mkiv, with no 
results)


Massi

Il 11/04/20 20:11, Wolfgang Schuster ha scritto:

Hans Hagen schrieb am 11.04.2020 um 19:41:

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)


Simpler, put the table in a frame.

\startuseMPgraphic{cell:triangle}
   draw llcorner OverlayBox
     -- lrcorner OverlayBox
     -- center topboundary OverlayBox
     -- cycle
    withcolor red ;
\stopuseMPgraphic

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

\starttext

\startframed[frame=off,offset=1ex,loffset=2ex,roffset=2ex,toffset=2ex,background=triangle] 


     \bTABLE[frame=off]
     \bTR
     \bTD[nx=2,align=middle] a\crlf text \eTD
     \eTR
     \bTR[toffset=1mm]
     \bTD left \eTD
     \bTD right \eTD
     \eTR
     \eTABLE
\stopframed

\stoptext

Wolfgang

___
If your question is of interest to others as well, please add an entry to the 
Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___


Re: [NTG-context] offset for background overlay

2020-04-11 Thread Wolfgang Schuster

Hans Hagen schrieb am 11.04.2020 um 19:41:

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)


Simpler, put the table in a frame.

\startuseMPgraphic{cell:triangle}
  draw llcorner OverlayBox
-- lrcorner OverlayBox
-- center topboundary OverlayBox
-- cycle
   withcolor red ;
\stopuseMPgraphic

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

\starttext

\startframed[frame=off,offset=1ex,loffset=2ex,roffset=2ex,toffset=2ex,background=triangle]
\bTABLE[frame=off]
\bTR
\bTD[nx=2,align=middle] a\crlf text \eTD
\eTR
\bTR[toffset=1mm]
\bTD left \eTD
\bTD right \eTD
\eTR
\eTABLE
\stopframed

\stoptext

Wolfgang
___
If your question is of interest to others as well, please add an entry to the 
Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___


Re: [NTG-context] offset for background overlay

2020-04-11 Thread Hans Hagen

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
-
___
If your question is of interest to others as well, please add an entry to the 
Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___


[NTG-context] offset for background overlay

2020-04-11 Thread mf

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

The triangle is used as background of the 2-column wide cell of the 
first row.


I want the triangle to go around the second row too, as if it were a 
frame for all the 3 cells. It means that it should be shifted down a bit.


So I tried this:

\startuseMPgraphic{cell:triangle}
  path p ; p := unittriangle rotated 90 xscaled 2.5 OverlayWidth 
yscaled 2.5 OverlayHeight ;

  draw p shifted (0,-3mm) withcolor red ;
\stopuseMPgraphic
...

but it does not work, because the content of the background is centered 
on the cell, so "shifted (0,-3mm)" has no effect.


The only solution I found is drawing something above the triangle with a 
neutral color, so that the whole background is centered in the cell and 
the red triangle goes down:


\startuseMPgraphic{cell:triangle}
  path p ; p := unittriangle rotated 90 xscaled 2.5 OverlayWidth 
yscaled 2.5 OverlayHeight ;

  fill p shifted (0,6mm) withcolor white ; % only to move the next one down
  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

It's a dirty trick. I'm sure there's a cleaner way.
Does anybody know it?

Thanks,
Massi
___
If your question is of interest to others as well, please add an entry to the 
Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___