ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* offset for background overlay
@ 2020-04-11 14:15 mf
  2020-04-11 17:41 ` Hans Hagen
  0 siblings, 1 reply; 7+ messages in thread
From: mf @ 2020-04-11 14:15 UTC (permalink / raw)
  To: mailing list for ConTeXt users

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
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2020-04-13 16:14 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-11 14:15 offset for background overlay mf
2020-04-11 17:41 ` Hans Hagen
2020-04-11 18:11   ` Wolfgang Schuster
2020-04-11 21:59     ` mf
2020-04-12  5:53       ` Wolfgang Schuster
2020-04-13 15:21         ` mf
2020-04-13 16:14           ` Wolfgang Schuster

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).