From: Hans Hagen <pragma@wxs.nl>
To: mailing list for ConTeXt users <ntg-context@ntg.nl>
Subject: Re: metafun
Date: Thu, 24 Mar 2016 19:22:49 +0100 [thread overview]
Message-ID: <56F43079.9000002@wxs.nl> (raw)
In-Reply-To: <CADawwoDyJymOUtrVBnidKrx57ZHteCeBnVHAmzORJ0p_URbW=Q@mail.gmail.com>
On 3/24/2016 6:24 PM, Piotr Kopszak wrote:
> P.S.
>
> For your conveniance, the minimal example:
>
> \startMPpositiongraphic{mypos:arrow}
> pair c[] ;
> initialize_box(\MPpos{\MPvar{self}});
> c[1] := cxy ;
> initialize_box(\MPpos{\MPvar{to}});
> c[2] := cxy ;
> drawarrow c[1] -- c[2] withpen pencircle scaled 2bp ;
> \stopMPpositiongraphic
> \startpositionoverlay{arrow}
> \setMPpositiongraphic{X-1}{mypos:arrow}{to=X-2}
> \setMPpositiongraphic{X-2}{mypos:arrow}{to=X-3}
> \stoppositionoverlay
> \defineoverlay[arrow][\positionoverlay{arrow}]
> \setupbackgrounds[page][background=arrow]
>
>
> \starttext
>
> \section {Anchors and layers}
>
> 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. This paragraph is keyed
> in as:
>
> \stoptext
The interface changed a bit
\setupMPvariables
[mpos:encircle]
[fillcolor=lightgray,
filloffset=0pt,
linecolor=blue,
lineoffset=5pt,
linewidth=1pt]
\startMPpositiongraphic{mpos:encircle}{linecolor,fillcolor,linewidth,lineoffset}
if unknown context_apos : input mp-apos.mpiv ; fi ;
\MPgetposboxes{\MPvar{self}}{\MPanchorid}
if nofposboxes = 1 :
posboxes[1] := posboxes[1] enlarged \MPvar{lineoffset} cornered
\MPvar{lineoffset} ;
fill posboxes[1] withcolor \MPvar{fillcolor} ;
draw posboxes[1] withpen pencircle scaled \MPvar{linewidth}
withcolor \MPvar{linecolor} ;
fi ;
\stopMPpositiongraphic
\setupMPvariables
[mpos:connect]
[linecolor=red,
lineoffset=.25ex,
linewidth=1pt]
\startMPpositiongraphic{mpos:connect}{linecolor,lineoffset,linewidth}
if unknown context_apos : input mp-apos.mpiv ; fi ;
boxlinewidth := \MPvar{linewidth} ;
boxlineoffset := \MPvar{lineoffset} ;
def boxlineoptions = withcolor \MPvar{linecolor} enddef ;
\MPgetposboxes{\MPvar{from},\MPvar{to}}{\MPanchorid}
connect_positions ;
\stopMPpositiongraphic
\starttext
\startpositionoverlay{text-1}
\setMPpositiongraphic{connect-1-b}{mpos:connect}{from=connect-1-b,to=connect-1-e}
\setMPpositiongraphic{connect-1-e}{mpos:connect}{from=connect-1-b,to=connect-1-e}
\stoppositionoverlay
\startpositionoverlay{text-1}
\setMPpositiongraphic{encircle-1}{mpos:encircle}{self=encircle-1}
\stoppositionoverlay
test \hpos{connect-1-b}{START}
\dorecurse{10}{\input ward}
\hpos{encircle-1}{\strut HERE}
\dorecurse{10}{\input ward}
\hpos{connect-1-e}{STOP} test
\stoptext
> 2016-03-24 18:23 GMT+01:00 Piotr Kopszak <kopszak@gmail.com>:
>> Hello list,
>>
>> The solution shown here no longer works with recent beta (indeed, it
>> probably ceased to work some time ago). How should it be corrected?
>>
>> Best
>>
>> Piotr
>>
>> 2010-10-24 0:14 GMT+02:00 Aditya Mahajan <adityam@umich.edu>:
>>> On Sat, 23 Oct 2010, Herbert Voss wrote:
>>>
>>>> It is a hard job to understand how all works ...
>>>
>>>
>>> I agree. That chapter is confusing if you do not know already how the
>>> mechanism
>>> works.
>>>
>>>> I tried to create the first example of the
>>>> documentation "Page 257 Anchors and layers",
>>>> but failed with mkii and iv. The page is created,
>>>> but without the graphical elements. Not using
>>>> \startbuffer--\stopbuffer makes no difference.
>>>
>>>
>>> You are simply setting the positions. You also need to tell ConTeXt to do
>>> something with the positions.
>>>
>>> 1. First define a position graphic that does something with the anchors that
>>> it is passed.
>>>
>>> \startMPpositiongraphic{mypos:arrow}
>>> pair c[] ;
>>> initialize_box(\MPpos{\MPvar{self}});
>>> c[1] := cxy ;
>>> initialize_box(\MPpos{\MPvar{to}});
>>> c[2] := cxy ;
>>> drawarrow c[1] -- c[2] withpen pencircle scaled 2bp ;
>>> \stopMPpositiongraphic
>>>
>>> cxy is the center of the box. See the defn of initialize_box in mp-core.mp
>>> for other values. I wish these were better documented.
>>>
>>> 2. Then define a position overlay that specifies the relation between the
>>> anchors.
>>>
>>> \startpositionoverlay{arrow}
>>> \setMPpositiongraphic{X-1}{mypos:arrow}{to=X-2}
>>> \setMPpositiongraphic{X-2}{mypos:arrow}{to=X-3}
>>> \stoppositionoverlay
>>>
>>>
>>> 3. Define an overlay that is mapped to MP position overlay.
>>>
>>> \defineoverlay[arrow][\positionoverlay{arrow}]
>>>
>>> 4. Hook the overlay as a page background
>>>
>>> \setupbackgrounds[page][background=arrow]
>>>
>>> 5. Then everything will work.
>>>
>>> \starttext
>>>
>>> \section {Anchors and layers}
>>>
>>> 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. This paragraph is keyed
>>> in as:
>>>
>>> \stoptext
>>>
>>> Aditya
>>> ___________________________________________________________________________________
>>> 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 : http://foundry.supelec.fr/projects/contextrev/
>>> wiki : http://contextgarden.net
>>> ___________________________________________________________________________________
>>
>>
>>
>> --
>> http://okle.pl
>
>
>
--
-----------------------------------------------------------------
Hans Hagen | PRAGMA ADE
Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
tel: 038 477 53 69 | 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 : http://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___________________________________________________________________________________
next prev parent reply other threads:[~2016-03-24 18:22 UTC|newest]
Thread overview: 41+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-10-23 19:34 metafun Herbert Voss
2010-10-23 22:14 ` metafun Aditya Mahajan
2016-03-24 17:23 ` metafun Piotr Kopszak
2016-03-24 17:24 ` metafun Piotr Kopszak
2016-03-24 18:14 ` metafun luigi scarso
2016-03-24 18:22 ` Hans Hagen [this message]
-- strict thread matches above, loose matches on Subject: below --
2021-02-20 16:27 metafun Hans Hagen
2021-02-20 17:43 ` metafun Otared Kavian
2021-02-20 21:19 ` metafun Hans Hagen
2010-10-20 12:03 metafun Hans Hagen
2010-10-20 12:11 ` metafun Mojca Miklavec
2010-10-20 12:23 ` metafun Martin Schröder
2010-10-20 12:49 ` metafun Vedran Miletić
2010-10-20 12:17 ` metafun Taco Hoekwater
2010-10-20 22:42 ` metafun Kevin D. Robbins
2010-10-21 7:10 ` metafun Hans Hagen
2010-10-22 14:06 ` metafun Taco Hoekwater
2010-10-22 14:20 ` metafun Hans Hagen
2010-10-22 14:22 ` metafun Taco Hoekwater
2010-10-22 15:29 ` metafun Otared Kavian
2010-10-22 16:09 ` metafun Kevin D. Robbins
2010-10-22 15:12 ` metafun Wolfgang Schuster
2010-10-22 15:28 ` metafun Hans Hagen
2010-10-23 10:49 ` metafun Alan BRASLAU
2004-06-23 15:03 metafun jimarin
[not found] ` <m2eko6gvg m.fsf@levana.de>
2004-06-23 15:11 ` metafun Patrick Gundlach
2004-06-23 15:26 ` metafun jimarin
2004-06-23 15:45 ` metafun Patrick Gundlach
2004-06-23 15:55 ` metafun jimarin
2004-06-23 16:03 ` metafun Patrick Gundlach
2004-06-24 8:13 ` metafun Hans Hagen
2001-09-16 9:13 metafun Hervé Rouault
2001-03-21 14:23 metafun guravage m.a.
2001-03-21 15:30 ` metafun Hans Hagen
2000-12-11 13:56 MetaFun Marc van Dongen
2000-12-12 15:35 ` MetaFun Ed L Cashin
2000-12-12 15:48 ` MetaFun Marc van Dongen
2000-12-12 16:18 ` MetaFun Ed L Cashin
2000-09-12 10:26 metafun Hans Hagen
2000-09-12 13:41 ` metafun Robert F. Beeger
[not found] ` <4.3.2.7.0.20000912152319.00b2ae30@rzdspc1.informatik.uni-h amburg.de>
2000-09-12 15:06 ` metafun Hans Hagen
2000-09-13 7:39 ` metafun Michal Kvasnicka
2000-07-17 0:45 (no) hyphenation Hans Hagen
2000-07-19 7:13 ` Hans Hagen
2000-07-24 20:20 ` metafun Hraban
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=56F43079.9000002@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).