ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
From: Hans Hagen <pragma@wxs.nl>
To: mailing list for ConTeXt users <ntg-context@ntg.nl>
Subject: Re: Weird behavior about metafun
Date: Tue, 08 Jan 2008 18:04:24 +0100	[thread overview]
Message-ID: <4783AD18.7060502@wxs.nl> (raw)
In-Reply-To: <769ba7780801080645v38743267td723dca613bc4cb6@mail.gmail.com>

Zhichu Chen wrote:
> Hi,
> 
> On Jan 7, 2008 11:52 PM, Aditya Mahajan <adityam@umich.edu> wrote:
> 
>>
>> Something like this:
>> http://www.fauskes.net/media/pgftikzexamples/PDF/todo-notes.pdf
>>
>> It will be nice to have a ConTeXt module that can do this.
> 
> 
> I've made a test file which is somewhat like what it shows, but I
> still have many problems so it's far from perfect.

stacking is already present



\setupcolors   [state=start]
\definecolor   [marginback] [darkcyan]

\startMPpositiongraphic{mypos:underline}
   initialize_box(\MPpos{\MPvar{self}}) ;
   path p ; p := (llxy--lrxy) shifted (0,dxy) ;
   pickup pencircle scaled 1pt ;
   draw p withcolor .75red ;
   anchor_box(\MPanchor{\MPvar{self}}) ;
\stopMPpositiongraphic

\startMPpositiongraphic{mypos:ulcorner}
   initialize_box(\MPpos{\MPvar{self}}) ;
   path p ; p := llxy--ulxy--urxy ;
   pickup pencircle scaled 1pt ;
   draw p withcolor .75red ;
   anchor_box(\MPanchor{\MPvar{self}}) ;
\stopMPpositiongraphic

\startMPpositiongraphic{mypos:torightmargin}
   path pa, pb, pab ; numeric na, nb ; pair bxya, lxyb ;
   initialize_box(\MPpos{\MPvar{from}}) ;
   na := nxy ; pa := (llxy--lrxy) shifted (0,dxy) ; bxya := (center pa) 
- (0 , \the\baselineskip/4) ;
   initialize_box(\MPpos{\MPvar{to}}) ;
   nb := nxy ; lxyb := .5[llxy , ulxy] - (\the\rightmargindistance/2 , 
0) ; pb := llxy--ulxy ;
   if na=nb :
     pab := center pa -- bxya -- (xpart lxyb , ypart bxya) -- lxyb -- 
center pb;
     pickup pencircle scaled 1pt ;
     draw pab withcolor transparent(1,.5,.625yellow) ;
     anchor_box(\MPanchor{\MPvar{from}}) ;
   fi ;
\stopMPpositiongraphic

\defineoverlay [margingraphics] [\positionoverlay{margingraphics}]

\setupbackgrounds
   [page]
   [background=margingraphics]

\starttext

\setupinmargin[stack=yes]

\defineframedtext
     [marginframe]
     [background=color,
%      backgroundcolor=marginback,
      offset=.25ex,
      frame=off,
      width=\the\rightmarginwidth,
      foregroundstyle=\bfx]

\def\marginstuff#1#2%
   {\doglobal\increment\currentmarginstuff
    \startpositionoverlay{margingraphics}%
       % can be drawn in one graphic which is more efficient
       \setMPpositiongraphic{mstuff:t\currentmarginstuff}{mypos:underline}%
       \setMPpositiongraphic{mstuff:m\currentmarginstuff}{mypos:ulcorner}%
 
\expanded{\setMPpositiongraphic{mstuff:t\currentmarginstuff}{mypos:torightmargin}{to=mstuff:m\currentmarginstuff}}%
    \stoppositionoverlay
 
\hpos{mstuff:t\currentmarginstuff}{#1}\inright{\hpos{mstuff:m\currentmarginstuff}{\marginframe{#2}}}}

First we have defined an \marginstuff {overlay}
{Just a test in a margin that could be multiple lines.}.
This overlay can be attached to some overlay layer, like, in our
case, the page. We define four small circles. These are drawn
as soon as the page overlay is typeset. Because they are located
in the background, they don't cover the text, while the lines do.
The previous paragraph was typeset by saying:

First we have defined an \marginstuff {overlay}
{Just a test in a margin that could be multiple lines.}.
First we have defined an \marginstuff {overlay}
{Just a test in a margin that could be multiple lines.}.
This overlay can be attached to some overlay layer, like, in our
case, the page. We define four small circles. These are drawn
as soon as the page overlay is typeset. Because they are located
in the background, they don't cover the text, while the lines do.
The previous paragraph was typeset by saying:

First we have defined an \marginstuff {overlay}
{Just a test in a margin that could be multiple lines.}.
First we have defined an \marginstuff {overlay}
{Just a test in a margin that could be multiple lines.}.
This overlay can be attached to some overlay layer, like, in our
case, the page. We define four small circles. These are drawn
as soon as the page overlay is typeset. Because they are located
in the background, they don't cover the text, while the lines do.

The previous paragraph was typeset by saying:
First we have defined an \marginstuff {overlay}
{Just a test in a margin that could be multiple lines.}.
First we have defined an \marginstuff {overlay}
{Just a test in a margin that could be multiple lines.}.
This overlay can be attached to some overlay layer, like, in our
case, the page. We define four small circles. These are drawn
as soon as the page overlay is typeset. Because they are located
in the background, they don't cover the text, while the lines do.
The previous paragraph was typeset by saying:

\stoptext


-----------------------------------------------------------------
                                           Hans Hagen | PRAGMA ADE
               Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
      tel: 038 477 53 69 | fax: 038 477 53 74 | www.pragma-ade.com
                                              | 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://tex.aanhet.net
archive  : https://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________


  parent reply	other threads:[~2008-01-08 17:04 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-01-07  2:45 Zhichu Chen
2008-01-07 11:50 ` Zhichu Chen
2008-01-07 13:41   ` Hans Hagen
2008-01-07 15:15     ` Zhichu Chen
2008-01-07 15:52 ` Aditya Mahajan
2008-01-08  1:43   ` Zhichu Chen
2008-01-08 14:45   ` Zhichu Chen
2008-01-08 15:00     ` Arthur Reutenauer
2008-01-08 17:04     ` Hans Hagen [this message]
2008-01-09  1:20       ` Zhichu Chen
2008-01-09 12:01       ` Wolfgang Schuster

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4783AD18.7060502@wxs.nl \
    --to=pragma@wxs.nl \
    --cc=ntg-context@ntg.nl \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).