ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
From: "Procházka Lukáš" <LPr@pontex.cz>
To: "mailing list for ConTeXt users" <ntg-context@ntg.nl>
Subject: Re: Layer vs. overlay
Date: Sat, 12 Jan 2013 11:36:36 +0100	[thread overview]
Message-ID: <op.wqsnrajk2ef5qg@lk-2008-nbk> (raw)
In-Reply-To: <3608C682-5ACB-4006-9CC7-9D848CB5BFC0@gmail.com>

Hello Wolfgang,

thank you for your very detailed answer.

I'll - try to understand how it works, try your examples what they'll produce...

Best regards,

Lukas


On Sat, 12 Jan 2013 08:44:21 +0100, Wolfgang Schuster <wolfgang.schuster@gmail.com> wrote:

>
> Am 11.01.2013 um 16:32 schrieb Procházka Lukáš Ing. - Pontex s. r. o. <LPr@pontex.cz>:
>
>> Hello,
>>
>> I need to add a text to the FOREGROUND of the page.
>>
>> - Layers can refer to a page (or its size) and elements in a layer are drawn BELLOW the (normal) page content.
>>
>> - Overlays are drawn ABOVE the (normal) page content and their size is given by an element (often \framed) which uses the overlay.
>>
>> So - I'd need a layer which would overlay the normal page content (like "foreground" or "topmost" layer) or an overlay which would refer to (= its size and position would depend on) the (current) page (instead of e.g. \framed);
>> it should be a somewhat combination of layers & overlays.
>>
>> How to achieve this in ConTeXt?
>
>
> Overlays and Layers are to different mechanism which are powerful when you combine both but first you have to know what each of them does.
>
>
> 1. Overlays
>
> ConTeXt has a overlay environment which cane used in the text to stack the arguments on the same spot. When take a close look at the example you can see each new element is placed on top of the previous element, when you remove the \strut in the argument you would also notice that each argument is placed horizontal and vertical centered.
>
> \setupbodyfont[40pt]
>
> \starttext
>
> \startoverlay
>   {\strut\red   m}
>   {\strut\green a}
>   {\strut\blue  l}
> \stopoverlay
>
> \stoptext
>
> After you do know now what overlays are I come to the real overlay mechanism.
>
> Overlays are created with the \defineoverlay command which takes a name for the overlay and its content. The overlays are then applied to a \framed command or the background to the page the textblock, header etc.
>
> In the next example I created two new overlays with the names “behind” and “before” (the name itself doesn’t matter) which I activated in the frame with tha background key.
>
> \starttext
>
> \defineoverlay[behind][{\blackrule[height=2cm,width=8cm,color=yellow]}]
> \defineoverlay[before][{\blackrule[height=8cm,width=2cm,color=orange]}]
>
> \framed
>   [width=10cm,
>    height=10cm,
>    background={color,behind,foreground,before},
>    backgroundcolor=red]
>   {\blackrule[width=6cm,height=6cm,color=blue]}
>
> \stoptext
>
> When you look at the arguments of the background key you can used two more names besides my own “behind” and “before” overlays. The first name in the list “color” is needed when you can to use the argument of the backgroundcolor key which puts a color two the whole area of the frame. The second name “foreground” is more interesting because with this you can place overlays *before* the content of the frame because “foreground” is the frame text itself.
>
> The differences between the overlay environment at the begin and the overlay mechanism for framed aren’t so big, only the methods to set them because in the first case you set the content for each level which the argument in braces ({…}{…}) and in the second case you define them first with \defineoverlay and set the order in the background key.
>
>
> 2. Layers
>
> When you have used layers the content of each layer was always centered in the frame but with layers you can put the content from each command at a certain horizontal and vertical position.
>
> In the following example I created a new layer and set three texts for it which are afterwards placed in the page which the \flushlayer command.
>
> \starttext
>
> \definelayer[test]
>
> \setlayer[test][x=3cm,y=6cm]{ONE}
> \setlayer[test][x=8cm,y=2cm]{TWO}
> \setlayer[test][x=2cm,y=9cm]{THREE}
>
> \flushlayer[test]
>
> \stoptext
>
> When you put new some text after \flushlayer would be surprised because it would end put on the following page but you shouldn’t wonder about this because layers have nothing to do with the page background or foreground.
>
> What makes the layer and overlay mechanism is interesting is when you combine them and put the \flushlayer command in a overlay which does now place the texts before or after the content of a frame. With my next example we’re finally in the process to combine them.
>
> \setupbodyfont[30pt]
>
> \starttext
>
> \definelayer[behindtext]
> \definelayer[beforetext]
>
> \setupbackgrounds[text][background={behindtext,foreground,beforetext}]
>
> \setlayer[behindtext][x=-2cm,y=.75ex]{\red    Behind}
> \setlayer[beforetext][x=+2cm,y=.75ex]{\yellow Before}
>
> The Text!
>
> \setlayer[behindtext][x=5cm,y=4cm]{\red    More background text!}
> \setlayer[beforetext][x=3cm,y=8cm]{\yellow More foreground text!}
>
> \stoptext
>
> When you look at the example you can see that haven't created a overlay for layer even though I said you need it to put the layer after the text. This isn’t necessary because when you create a new layer context does also create a overlay with the same name in which the layer is placed. The other question is how you can place overlays on the text/page when I told before overalls can only be placed on frame, this is possible because all page elements (textblock, header, footer and even the page and paper itself) are frames. Even though these elements are frames they don’t provide all the options from \framed because they are a special version with less functionality.
>
> 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
> ___________________________________________________________________________________


___________________________________________________________________________________
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:[~2013-01-12 10:36 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-01-11 15:32 Procházka Lukáš Ing. - Pontex s. r. o.
2013-01-11 18:06 ` Hans Hagen
2013-01-12  7:44 ` Wolfgang Schuster
2013-01-12 10:36   ` Procházka Lukáš [this message]
2013-01-12 13:25   ` Hans Hagen
2013-01-12 17:54   ` [***Spam/VIR***] " Procházka Lukáš
2013-01-12 18:11     ` Wolfgang Schuster
2013-01-15  8:04       ` Procházka Lukáš Ing. - Pontex s. r. o.
2013-01-15 10:09         ` Wolfgang Schuster
2013-01-15 12:10           ` [***Spam/VIR***] " Procházka Lukáš Ing. - Pontex s. r. o.
2013-01-15 12:25             ` Aditya Mahajan
2013-01-15 16:21               ` Philipp Gesang
2013-01-16  8:41               ` Procházka Lukáš Ing. - Pontex s. r. o.
2013-01-16 11:47                 ` Philipp Gesang
2013-01-16 13:09                   ` Procházka Lukáš Ing. - Pontex s. r. o.
2013-01-16 13:34                     ` Philipp Gesang

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=op.wqsnrajk2ef5qg@lk-2008-nbk \
    --to=lpr@pontex.cz \
    --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).