ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* what is nxy?
@ 2000-10-18 20:41 Denis B. Roegel
  2000-10-19  9:10 ` Hans Hagen
  0 siblings, 1 reply; 2+ messages in thread
From: Denis B. Roegel @ 2000-10-18 20:41 UTC (permalink / raw)
  Cc: Denis B. Roegel

If I go back to the example of an earlier question of mine,
I see that

  1) I don't understand what `nxy' is; as far as I can see,
     it is not explained in the metafun manual;
  2) I don't understand why the connection between the first
     and the second word goes from center to center, 
     and this may have something to do with 1).

Thanks!

Denis

\starttext

\startMPpositiongraphic{mypos:circle}
  initialize_box(\MPpos{\MPvar{self}});
  path p; p:=llxy..lrxy..urxy..ulxy..cycle;
  pickup pencircle scaled 1pt;
  fill p withcolor .800white;
  draw p withcolor .625yellow;
  anchor_box(\MPanchor{\MPvar{self}});
\stopMPpositiongraphic

\startMPpositiongraphic{mypos:line}
  path pa, pb, pab ; numeric na, nb;
  initialize_box(\MPpos{\MPvar{from}});
  na := nxy ; pa := llxy..lrxy..urxy..ulxy..cycle ;
  initialize_box(\MPpos{\MPvar{to}});
  nb := nxy ; pb := llxy..lrxy..urxy..ulxy..cycle ;
  if na=nb :
    pab := center pa -- center pb ;
    pab := pab cutbefore (pab intersectionpoint pa) ;
    pab := pab cutafter (pab intersectionpoint pb) ;
    pickup pencircle scaled 1pt;
    drawarrow pab withcolor .625yellow;
    anchor_box(\MPanchor{\MPvar{from}});
  fi;
\stopMPpositiongraphic

\startpositionoverlay{backgraphics} 
\setMPpositiongraphic{X-1}{mypos:circle}
\setMPpositiongraphic{X-2}{mypos:circle}
\setMPpositiongraphic{X-3}{mypos:circle}
\stoppositionoverlay
\startpositionoverlay{foregraphics}
\setMPpositiongraphic{X-1}{mypos:line}{to=X-2}
\setMPpositiongraphic{X-2}{mypos:line}{to=X-3}
\stoppositionoverlay

\defineoverlay [foregraphics] [\positionoverlay{foregraphics}]
\defineoverlay [backgraphics] [\positionoverlay{backgraphics}]

\setupbackgrounds
    [page]
    [background={backgraphics,foreground,foregraphics}]

In a previous section we saw that some \hpos {X-1} {words} were
\hpos {X-2} {circled} and connected by an \hpos {X-3} {arrow}.
As with most things in \CONTEXT, marking these words is separated
from declaring what to do with those words. 

\stoptext


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

* Re: what is nxy?
  2000-10-18 20:41 what is nxy? Denis B. Roegel
@ 2000-10-19  9:10 ` Hans Hagen
  0 siblings, 0 replies; 2+ messages in thread
From: Hans Hagen @ 2000-10-19  9:10 UTC (permalink / raw)
  Cc: ntg-context, Denis B. Roegel

At 10:41 PM 10/18/00 +0200, Denis B. Roegel wrote:
>If I go back to the example of an earlier question of mine,
>I see that
>
>  1) I don't understand what `nxy' is; as far as I can see,
>     it is not explained in the metafun manual;
>  2) I don't understand why the connection between the first
>     and the second word goes from center to center, 
>     and this may have something to do with 1).

>\startMPpositiongraphic{mypos:line}
>  path pa, pb, pab ; numeric na, nb;
>  initialize_box(\MPpos{\MPvar{from}});
>  na := nxy ; pa := llxy..lrxy..urxy..ulxy..cycle ;

The initialize_box macro sets a bunch of vars [still to be explained in
this chapter btw] and nxy is the pagenumber associates with the pos. 

>  initialize_box(\MPpos{\MPvar{to}});
>  nb := nxy ; pb := llxy..lrxy..urxy..ulxy..cycle ;
>  if na=nb :

So, we only draw a graphic when both positions are on the same page. [i do
have an alternative that handles multiple pages]. In the background graphic
that goes behind the text [area] this page number info is used to let the
background cross the page. 

Concerning (2): the "center" directive makes that happen 

Hans
-------------------------------------------------------------------------
                                                  Hans Hagen | PRAGMA ADE
                      Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
 tel: +31 (0)38 477 53 69 | fax: +31 (0)38 477 53 74 | www.pragma-ade.com
-------------------------------------------------------------------------


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

end of thread, other threads:[~2000-10-19  9:10 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2000-10-18 20:41 what is nxy? Denis B. Roegel
2000-10-19  9:10 ` Hans Hagen

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