ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
From: Wolfgang Schuster <schuster.wolfgang@googlemail.com>
To: mailing list for ConTeXt users <ntg-context@ntg.nl>
Subject: Re: Position of MetaPost graphics
Date: Mon, 4 Apr 2011 09:33:30 +0200	[thread overview]
Message-ID: <E64D980C-3E7F-4E57-B8F4-E1294AB1C790@googlemail.com> (raw)
In-Reply-To: <BANLkTin7R5oLM1zzygj0e49wUkBnezOCYA@mail.gmail.com>


Am 04.04.2011 um 01:22 schrieb Tim Steenvoorden:

> Thanks Peter! You are right it is easier to draw both the wave and the
> line in Metapost. And the dx=-\cutspace is just what I needed for left
> pages!
> 
> I striped the frames out of the code and placed just the graphics in
> the layer with a reuseMPgraphic. Also, I pulled out the definition of
> the wave into a MPinclusions. I have to do LoadPageState in each
> graphic though.
> 
> %\showframe
> \setuppapersize[A5][A5]
> \setuppagenumbering[alternative=doublesided]
> 
> \startMPinclusions
> numeric periods, width;
> path wave;
> periods := 3 + 1/4;
> width   := periods * 2*pi;
> wave    := origin for x=0 step 0.1 until width:
>             .. (x,x*sin(x))
>           endfor;
> \stopMPinclusions
> 
> \startreusableMPgraphic{rightwave}
> LoadPageState;
> pickup pencircle scaled 1pt;
> draw origin -- (TextWidth,0) -- wave xscaled (CutSpace/width) yscaled
> (LineHeight/width) shifted (TextWidth,0);
> %setbounds currentpicture to unitsquare xscaled (TextWidth+CutSpace);
> \stopreusableMPgraphic
> 
> \startreusableMPgraphic{leftwave}
> LoadPageState;
> pickup pencircle scaled 1pt;
> draw reverse wave xscaled (-1*CutSpace/width) yscaled
> (LineHeight/width) -- (TextWidth,0);
> \stopreusableMPgraphic
> 
> \definelayer[decorations][position=yes,option=test]
> \setupbackgrounds[page][background=decorations]
> 
> \starttext
> 
> {\ss\bfc A chapter title}
> \blank[small]
> {\ss\bfx \date \hfill Author Name}
> \setlayer[decorations][location=r]{\reuseMPgraphic{rightwave}}
> 
> \input knuth
> 
> \page
> 
> {\ss\bfc A very long chapter title on two or more lines}
> \blank[small]
> {\ss\bfx \date \hfill Author Name}
> \setlayer[decorations][location=r,dx=-\cutspace]{\reuseMPgraphic{leftwave}}
> 
> \input knuth
> 
> \stoptext
> 
> Just one problem is left. The graphic occupies space in the text layer
> as if the location was set to rb. If you place it with the position=no
> option, it is properly placed in the background and it doesn't disturb
> the text. Is this a bug or a feature?
> 
> I tried to play a bit with the bounding boxes, but I think I don't
> understand them that well.

Your problem is that you use {\ss\bfc …} etc. to place the title
rather than contexts \title command where you can define your own
command. With such a command you can put all text in a frame with
your graphic a background.

- http://wiki.contextgarden.net/Generate_Authorlist_from_Head_Content
- http://wiki.contextgarden.net/Titles#A_complex_graphical_element_under_the_chapter_title

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://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________


  reply	other threads:[~2011-04-04  7:33 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-04-01  9:39 Tim Steenvoorden
2011-04-03 15:33 ` Peter Rolf
2011-04-03 16:42 ` Aditya Mahajan
     [not found] ` <4D9859C6.9040200@wxs.nl>
2011-04-03 23:22   ` Tim Steenvoorden
2011-04-04  7:33     ` Wolfgang Schuster [this message]
2011-04-06 14:04       ` Tim Steenvoorden

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=E64D980C-3E7F-4E57-B8F4-E1294AB1C790@googlemail.com \
    --to=schuster.wolfgang@googlemail.com \
    --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).