ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* Layer vs. overlay
@ 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
  0 siblings, 2 replies; 16+ messages in thread
From: Procházka Lukáš Ing. - Pontex s. r. o. @ 2013-01-11 15:32 UTC (permalink / raw)
  To: ConTeXt

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?

Best regards,

Lukas



-- 
Ing. Lukáš Procházka [mailto:LPr@pontex.cz]
Pontex s. r. o.      [mailto:pontex@pontex.cz] [http://www.pontex.cz]
Bezová 1658
147 14 Praha 4

Tel: +420 244 062 238
Fax: +420 244 461 038

___________________________________________________________________________________
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
___________________________________________________________________________________


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

* Re: Layer vs. overlay
  2013-01-11 15:32 Layer vs. overlay Procházka Lukáš Ing. - Pontex s. r. o.
@ 2013-01-11 18:06 ` Hans Hagen
  2013-01-12  7:44 ` Wolfgang Schuster
  1 sibling, 0 replies; 16+ messages in thread
From: Hans Hagen @ 2013-01-11 18:06 UTC (permalink / raw)
  To: mailing list for ConTeXt users

On 1/11/2013 4:32 PM, Procházka Lukáš Ing. - Pontex s. r. o. wrote:
> 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?

background={whaveter,another,foreground,alastone}

so 'foreground' will do it

-----------------------------------------------------------------
                                           Hans Hagen | PRAGMA ADE
               Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
     tel: 038 477 53 69 | voip: 087 875 68 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  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________


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

* Re: Layer vs. overlay
  2013-01-11 15:32 Layer vs. overlay 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áš
                     ` (2 more replies)
  1 sibling, 3 replies; 16+ messages in thread
From: Wolfgang Schuster @ 2013-01-12  7:44 UTC (permalink / raw)
  To: mailing list for ConTeXt users


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
___________________________________________________________________________________

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

* Re: Layer vs. overlay
  2013-01-12  7:44 ` Wolfgang Schuster
@ 2013-01-12 10:36   ` Procházka Lukáš
  2013-01-12 13:25   ` Hans Hagen
  2013-01-12 17:54   ` [***Spam/VIR***] " Procházka Lukáš
  2 siblings, 0 replies; 16+ messages in thread
From: Procházka Lukáš @ 2013-01-12 10:36 UTC (permalink / raw)
  To: mailing list for ConTeXt users

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
___________________________________________________________________________________

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

* Re: Layer vs. overlay
  2013-01-12  7:44 ` Wolfgang Schuster
  2013-01-12 10:36   ` Procházka Lukáš
@ 2013-01-12 13:25   ` Hans Hagen
  2013-01-12 17:54   ` [***Spam/VIR***] " Procházka Lukáš
  2 siblings, 0 replies; 16+ messages in thread
From: Hans Hagen @ 2013-01-12 13:25 UTC (permalink / raw)
  To: mailing list for ConTeXt users; +Cc: Wolfgang Schuster

On 1/12/2013 8:44 AM, Wolfgang Schuster wrote:

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

 > ...

perfect explanation

Hans

-----------------------------------------------------------------
                                           Hans Hagen | PRAGMA ADE
               Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
     tel: 038 477 53 69 | voip: 087 875 68 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  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________


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

* Re: [***Spam/VIR***] Re:  Layer vs. overlay
  2013-01-12  7:44 ` Wolfgang Schuster
  2013-01-12 10:36   ` Procházka Lukáš
  2013-01-12 13:25   ` Hans Hagen
@ 2013-01-12 17:54   ` Procházka Lukáš
  2013-01-12 18:11     ` Wolfgang Schuster
  2 siblings, 1 reply; 16+ messages in thread
From: Procházka Lukáš @ 2013-01-12 17:54 UTC (permalink / raw)
  To: mailing list for ConTeXt users

[-- Attachment #1: Type: text/plain, Size: 6854 bytes --]

Hello Wolfgang,

some more attempts:

The sample Lay3 is simple enough and brings some text to the top of the page:

----
\setupbodyfont[30pt]
\setuplayout[page]

\starttext
   \definelayer[beforetext]

   \setupbackgrounds
     [page]
     [background={foreground,beforetext}]

   \setlayer[beforetext]{\red BEFORE}

   The Text!
\stoptext
----

This works well.

The Lay4 differs in one point - it encloses the text into \start/stop-TEXpage:

----
\setupbodyfont[30pt]

\starttext
   \startTEXpage
     \definelayer[beforetext]

     \setupbackgrounds
       [page]
       [background={foreground,beforetext}]

     \setlayer[beforetext]{\red BEFORE}

     The Text!
   \stopTEXpage
\stoptext
----

In the latter case, the red text "BEFORE" doesn't appear.

What's wrong? How to make it appear?

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
> ___________________________________________________________________________________

[-- Attachment #2: Lay3.mkiv --]
[-- Type: application/octet-stream, Size: 227 bytes --]

\setupbodyfont[30pt]
\setuplayout[page]

\starttext
  \definelayer[beforetext]

  \setupbackgrounds
    [page]
    [background={foreground,beforetext}]

  \setlayer[beforetext]{\red BEFORE}

  The Text!
\stoptext

[-- Attachment #3: Lay3.pdf --]
[-- Type: application/pdf, Size: 5810 bytes --]

[-- Attachment #4: Lay4.mkiv --]
[-- Type: application/octet-stream, Size: 252 bytes --]

\setupbodyfont[30pt]

\starttext
  \startTEXpage
    \definelayer[beforetext]

    \setupbackgrounds
      [page]
      [background={foreground,beforetext}]

    \setlayer[beforetext]{\red BEFORE}

    The Text!
  \stopTEXpage
\stoptext

[-- Attachment #5: Lay4.pdf --]
[-- Type: application/pdf, Size: 5153 bytes --]

[-- Attachment #6: Type: text/plain, Size: 485 bytes --]

___________________________________________________________________________________
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
___________________________________________________________________________________

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

* Re: Layer vs. overlay
  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.
  0 siblings, 1 reply; 16+ messages in thread
From: Wolfgang Schuster @ 2013-01-12 18:11 UTC (permalink / raw)
  To: mailing list for ConTeXt users


Am 12.01.2013 um 18:54 schrieb Procházka Lukáš <LPr@pontex.cz>:

> Hello Wolfgang,
> 
> some more attempts:
> 
> The sample Lay3 is simple enough and brings some text to the top of the page:
> 
> ----
> \setupbodyfont[30pt]
> \setuplayout[page]
> 
> \starttext
>  \definelayer[beforetext]
> 
>  \setupbackgrounds
>    [page]
>    [background={foreground,beforetext}]
> 
>  \setlayer[beforetext]{\red BEFORE}
> 
>  The Text!
> \stoptext
> ----
> 
> This works well.
> 
> The Lay4 differs in one point - it encloses the text into \start/stop-TEXpage:
> 
> ----
> \setupbodyfont[30pt]
> 
> \starttext
>  \startTEXpage
>    \definelayer[beforetext]
> 
>    \setupbackgrounds
>      [page]
>      [background={foreground,beforetext}]
> 
>    \setlayer[beforetext]{\red BEFORE}
> 
>    The Text!
>  \stopTEXpage
> \stoptext
> ----
> 
> In the latter case, the red text "BEFORE" doesn't appear.
> 
> What's wrong? How to make it appear?

Move \definelayer and \setupbackgrounds *before* \startTEXpage because the environment creates a local group and you background setup is lost.

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
___________________________________________________________________________________


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

* Re: Layer vs. overlay
  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
  0 siblings, 1 reply; 16+ messages in thread
From: Procházka Lukáš Ing. - Pontex s. r. o. @ 2013-01-15  8:04 UTC (permalink / raw)
  To: mailing list for ConTeXt users

On Sat, 12 Jan 2013 19:11:47 +0100, Wolfgang Schuster <wolfgang.schuster@gmail.com> wrote:

> Move \definelayer and \setupbackgrounds *before* \startTEXpage because the environment creates a local group and you background setup is lost.

... Thanks for the hint - here's my next trial.

It should write "BEFORE" to tho top right corner of the page.

----
\setupbodyfont[30pt]

\starttext
   A

   \bgroup
     \definelayer[beforetext][width=\paperwidth,preset=righttop]

     \setupbackgrounds
       [page]
       [background={foreground,beforetext}]

     \startTEXpage
       \setlayer[beforetext]{\framed[width=2in]{BEFORE}}
       \externalfigure[cow][width=30cm]
     \stopTEXpage
   \egroup

   Z
\stoptext
----

The problem now is the layer "beforetext" has width of the page in the moment is is defined - 21 cm.

But the layer is supposed to be used later inside \start/stop-TEXpage whose page size may be arbitrary, or better, the size will result from the content it will contain.

In my example - an image of 30 cm width is to define the page size.

And the text "BEFORE" is not put to the top right corner of the (30 cm) page (what I'd like to achieve) but to cca 2 thirds of these 30 cm (given by \pagewidth which was 21 cm at the moment of definition).

I would probably need a way to alter the layer size to the current content...

Or any other way to place something to the top right corner of the page from within \start/stop-TEXpage, where page size is not known in advance?

Best regards,

Lukas


-- 
Ing. Lukáš Procházka [mailto:LPr@pontex.cz]
Pontex s. r. o.      [mailto:pontex@pontex.cz] [http://www.pontex.cz]
Bezová 1658
147 14 Praha 4

Tel: +420 244 062 238
Fax: +420 244 461 038

___________________________________________________________________________________
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
___________________________________________________________________________________


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

* Re: Layer vs. overlay
  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.
  0 siblings, 1 reply; 16+ messages in thread
From: Wolfgang Schuster @ 2013-01-15 10:09 UTC (permalink / raw)
  To: mailing list for ConTeXt users


Am 15.01.2013 um 09:04 schrieb Procházka Lukáš Ing. - Pontex s. r. o. <LPr@pontex.cz>:

> On Sat, 12 Jan 2013 19:11:47 +0100, Wolfgang Schuster <wolfgang.schuster@gmail.com> wrote:
> 
>> Move \definelayer and \setupbackgrounds *before* \startTEXpage because the environment creates a local group and you background setup is lost.
> 
> ... Thanks for the hint - here's my next trial.
> 
> It should write "BEFORE" to tho top right corner of the page.
> 
> ----
> \setupbodyfont[30pt]
> 
> \starttext
>  A
> 
>  \bgroup
>    \definelayer[beforetext][width=\paperwidth,preset=righttop]
> 
>    \setupbackgrounds
>      [page]
>      [background={foreground,beforetext}]
> 
>    \startTEXpage
>      \setlayer[beforetext]{\framed[width=2in]{BEFORE}}
>      \externalfigure[cow][width=30cm]
>    \stopTEXpage
>  \egroup
> 
>  Z
> \stoptext
> ----
> 
> The problem now is the layer "beforetext" has width of the page in the moment is is defined - 21 cm.
> 
> But the layer is supposed to be used later inside \start/stop-TEXpage whose page size may be arbitrary, or better, the size will result from the content it will contain.
> 
> In my example - an image of 30 cm width is to define the page size.
> 
> And the text "BEFORE" is not put to the top right corner of the (30 cm) page (what I'd like to achieve) but to cca 2 thirds of these 30 cm (given by \pagewidth which was 21 cm at the moment of definition).
> 
> I would probably need a way to alter the layer size to the current content...
> 
> Or any other way to place something to the top right corner of the page from within \start/stop-TEXpage, where page size is not known in advance?

\setupbodyfont[30pt]

\starttext

A

\definelayer  [beforetext][width=\overlaywidth,height=\overlayheight]
\defineoverlay[beforetext][{\setups[beforetext]\tightlayer[beforetext]}]

\startsetups[beforetext]
  \setlayer[beforetext][preset=righttop]{\framed[width=2in]{BEFORE}}
\stopsetups

\startTEXpage[background={foreground,beforetext}]
  \externalfigure[cow][width=30cm]
\stopTEXpage

Z

\stoptext

A similar example is also on the wiki: http://wiki.contextgarden.net/Layers#Place_labels_on_pictures

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
___________________________________________________________________________________


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

* Re: [***Spam/VIR***] Re:  Layer vs. overlay
  2013-01-15 10:09         ` Wolfgang Schuster
@ 2013-01-15 12:10           ` Procházka Lukáš Ing. - Pontex s. r. o.
  2013-01-15 12:25             ` Aditya Mahajan
  0 siblings, 1 reply; 16+ messages in thread
From: Procházka Lukáš Ing. - Pontex s. r. o. @ 2013-01-15 12:10 UTC (permalink / raw)
  To: mailing list for ConTeXt users

... Thanks again.

On Tue, 15 Jan 2013 11:09:48 +0100, Wolfgang Schuster <wolfgang.schuster@gmail.com> wrote:

> \setupbodyfont[30pt]
>
> \starttext
>
> A
>
> \definelayer  [beforetext][width=\overlaywidth,height=\overlayheight]
> \defineoverlay[beforetext][{\setups[beforetext]\tightlayer[beforetext]}]
>
> \startsetups[beforetext]
>   \setlayer[beforetext][preset=righttop]{\framed[width=2in]{BEFORE}}
> \stopsetups
>
> \startTEXpage[background={foreground,beforetext}]
>   \externalfigure[cow][width=30cm]
> \stopTEXpage
>
> Z
>
> \stoptext
>
> A similar example is also on the wiki: http://wiki.contextgarden.net/Layers#Place_labels_on_pictures

Yes, I started altering it... But I wans't sure abou relation layers vs. overlays vs. setups.

I'd need also to add some dynamically generated content, something like \pagenumber in the wiki example, but to be generated by Lua.

So I extended your example:

----
\setupbodyfont[30pt]

\starttext
   A

   \definelayer  [beforetext][width=\overlaywidth,height=\overlayheight]
   \defineoverlay[beforetext][{\setups[beforetext]\tightlayer[beforetext]}]

   \startsetups[beforetext]
     \setlayer[beforetext][preset=righttop]{\framed[width=2in]{\directlua{context(userdata.LPr.text)}}}
   \stopsetups

   \startTEXpage[background={foreground,beforetext}]
     \startluacode
       userdata = userdata or {}
       userdata.LPr = userdata.LPr or {}
       userdata.LPr.text = "BEF"

       context.externalfigure({"cow"},{width="30cm"})
     \stopluacode
   \stopTEXpage

   Z
\stoptext
----

I believe I used a proper way; if not so, please correct "bad places".

(Finally: I'd like to achieve a Lua function which will copy all pages of a .pdf file, keeping size of each page, and adding a customizable string with page-in-the-pdf number (with default value "<page-i>/<n-pages>"), being placed to the right top corner of the i-th page. All to be provided by Lua.)

Thanks again.

Best regards,

Lukas

> Wolfgang


-- 
Ing. Lukáš Procházka [mailto:LPr@pontex.cz]
Pontex s. r. o.      [mailto:pontex@pontex.cz] [http://www.pontex.cz]
Bezová 1658
147 14 Praha 4

Tel: +420 244 062 238
Fax: +420 244 461 038

___________________________________________________________________________________
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
___________________________________________________________________________________


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

* Re: [***Spam/VIR***] Re: Layer vs. overlay
  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.
  0 siblings, 2 replies; 16+ messages in thread
From: Aditya Mahajan @ 2013-01-15 12:25 UTC (permalink / raw)
  To: mailing list for ConTeXt users

[-- Attachment #1: Type: TEXT/PLAIN, Size: 998 bytes --]

On Tue, 15 Jan 2013, Procházka Lukáš Ing. - Pontex s. r. o. wrote:

> (Finally: I'd like to achieve a Lua function which will copy all pages of a 
> .pdf file, keeping size of each page, and adding a customizable string with 
> page-in-the-pdf number (with default value "<page-i>/<n-pages>"), being 
> placed to the right top corner of the i-th page. All to be provided by Lua.)

A few years ago I wrote a module that, amongst other things, did this. 
(The mail purpose of the module was to cut 2 column journal papers to one 
column PDF so that they are easy to read on an eink reader. I haven't used 
this in a while, so it may not work out of the box).

https://github.com/adityam/cut-n-paste/blob/master/tex/context/third/cut-n-paste/t-cut-n-paste.tex

In this case, I used a MetaPost overylay to draw the page number (search 
for cnp:text). The user could manipulate the location of the page number 
by using the location key (which had to be a valid Metapost pair).

Aditya

[-- Attachment #2: Type: text/plain, Size: 485 bytes --]

___________________________________________________________________________________
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
___________________________________________________________________________________

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

* Re: [***Spam/VIR***] Re: Layer vs. overlay
  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.
  1 sibling, 0 replies; 16+ messages in thread
From: Philipp Gesang @ 2013-01-15 16:21 UTC (permalink / raw)
  To: mailing list for ConTeXt users


[-- Attachment #1.1: Type: text/plain, Size: 1114 bytes --]

···<date: 2013-01-15, Tuesday>···<from: Aditya Mahajan>···

> On Tue, 15 Jan 2013, Procházka Lukáš Ing. - Pontex s. r. o. wrote:
> 
> >(Finally: I'd like to achieve a Lua function which will copy all
> >pages of a .pdf file, keeping size of each page, and adding a
> >customizable string with page-in-the-pdf number (with default
> >value "<page-i>/<n-pages>"), being placed to the right top corner
> >of the i-th page. All to be provided by Lua.)
> 
> A few years ago I wrote a module that, amongst other things, did
> this. (The mail purpose of the module was to cut 2 column journal
> papers to one column PDF so that they are easy to read on an eink
> reader. I haven't used this in a while, so it may not work out of
> the box).
> 
> https://github.com/adityam/cut-n-paste/blob/master/tex/context/third/cut-n-paste/t-cut-n-paste.tex

It works reliably with recent versions. I use it quite a lot atm
for a project that requires compiling several individual
documents into larger ones and it has never failed me so far.
Thanks, btw, this saves some work!

Regards
Philipp


[-- Attachment #1.2: Type: application/pgp-signature, Size: 198 bytes --]

[-- Attachment #2: Type: text/plain, Size: 485 bytes --]

___________________________________________________________________________________
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
___________________________________________________________________________________

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

* Re: [***Spam/VIR***] Re: Layer vs. overlay
  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
  1 sibling, 1 reply; 16+ messages in thread
From: Procházka Lukáš Ing. - Pontex s. r. o. @ 2013-01-16  8:41 UTC (permalink / raw)
  To: mailing list for ConTeXt users

[-- Attachment #1: Type: text/plain, Size: 2536 bytes --]

Hello,

@Aditya: Thanks for the tip - maybe some inspiration for me.


Anyway, I keep on trying to create my previously described function with Lua.

Now, I have a code which does much expected, but I'm not able to pass the desired content to setups/layer:

----
\setupbodyfont[30pt]

\starttext
   A

   \definelayer  [beforetext][width=\overlaywidth,height=\overlayheight]
   \defineoverlay[beforetext][{\setups[beforetext]\tightlayer[beforetext]}]

   \startsetups[beforetext]
     \setlayer[beforetext][preset=righttop]{\framed[width=2in]{\directlua{context(userdata.LPr.text)}}}
   \stopsetups

   \startluacode
     userdata = userdata or {}
     userdata.LPr = userdata.LPr or {}

     for i = 1, 2 do
       context.startTEXpage{background="foreground,beforetext"}
         userdata.LPr.text = "BEF" .. i

         context.externalfigure({"cow"},{width="30cm"})
       context.stopTEXpage()
     end
   \stopluacode

   Z
\stoptext
----

Both images of the cow have "BEF2" in the top right corner, but there should be "BEF1" on the former and "BEF2" on the latter.

I'm trying to pass the text string ("BEF" .. i) via userdata, but it doesn't work.

So how to do it?

Lukas



On Tue, 15 Jan 2013 13:25:04 +0100, Aditya Mahajan <adityam@umich.edu> wrote:

> On Tue, 15 Jan 2013, Procházka Lukáš Ing. - Pontex s. r. o. wrote:
>
>> (Finally: I'd like to achieve a Lua function which will copy all pages of a
>> .pdf file, keeping size of each page, and adding a customizable string with
>> page-in-the-pdf number (with default value "<page-i>/<n-pages>"), being
>> placed to the right top corner of the i-th page. All to be provided by Lua.)
>
> A few years ago I wrote a module that, amongst other things, did this.
> (The mail purpose of the module was to cut 2 column journal papers to one
> column PDF so that they are easy to read on an eink reader. I haven't used
> this in a while, so it may not work out of the box).
>
> https://github.com/adityam/cut-n-paste/blob/master/tex/context/third/cut-n-paste/t-cut-n-paste.tex
>
> In this case, I used a MetaPost overylay to draw the page number (search
> for cnp:text). The user could manipulate the location of the page number
> by using the location key (which had to be a valid Metapost pair).
>
> Aditya


-- 
Ing. Lukáš Procházka [mailto:LPr@pontex.cz]
Pontex s. r. o.      [mailto:pontex@pontex.cz] [http://www.pontex.cz]
Bezová 1658
147 14 Praha 4

Tel: +420 244 062 238
Fax: +420 244 461 038

[-- Attachment #2: Lay8.mkiv --]
[-- Type: application/octet-stream, Size: 687 bytes --]

\setupbodyfont[30pt]

\starttext
  A

  \definelayer  [beforetext][width=\overlaywidth,height=\overlayheight]
  \defineoverlay[beforetext][{\setups[beforetext]\tightlayer[beforetext]}]

  \startsetups[beforetext]
    \setlayer[beforetext][preset=righttop]{\framed[width=2in]{\directlua{context(userdata.LPr.text)}}}
  \stopsetups

  \startluacode
    userdata = userdata or {}
    userdata.LPr = userdata.LPr or {}

    for i = 1, 2 do
      context.startTEXpage{background="foreground,beforetext"}
        userdata.LPr.text = "BEF" .. i

        context.externalfigure({"cow"},{width="30cm"})
      context.stopTEXpage()
    end
  \stopluacode

  Z
\stoptext

[-- Attachment #3: Lay8.pdf --]
[-- Type: application/pdf, Size: 11092 bytes --]

[-- Attachment #4: Type: text/plain, Size: 485 bytes --]

___________________________________________________________________________________
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
___________________________________________________________________________________

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

* Re: [***Spam/VIR***] Re: Layer vs. overlay
  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.
  0 siblings, 1 reply; 16+ messages in thread
From: Philipp Gesang @ 2013-01-16 11:47 UTC (permalink / raw)
  To: mailing list for ConTeXt users


[-- Attachment #1.1: Type: text/plain, Size: 2680 bytes --]

···<date: 2013-01-16, Wednesday>···<from: Procházka Lukáš Ing. - Pontex s. r. o.>···

> Now, I have a code which does much expected, but I'm not able to pass the desired content to setups/layer:
> 
> ----
> \setupbodyfont[30pt]
> 
> \starttext
>   A
> 
>   \definelayer  [beforetext][width=\overlaywidth,height=\overlayheight]
>   \defineoverlay[beforetext][{\setups[beforetext]\tightlayer[beforetext]}]
> 
>   \startsetups[beforetext]
>     \setlayer[beforetext][preset=righttop]{\framed[width=2in]{\directlua{context(userdata.LPr.text)}}}
>   \stopsetups
> 
>   \startluacode
>     userdata = userdata or {}
>     userdata.LPr = userdata.LPr or {}
> 
>     for i = 1, 2 do
>       context.startTEXpage{background="foreground,beforetext"}
>         userdata.LPr.text = "BEF" .. i
> 
>         context.externalfigure({"cow"},{width="30cm"})
>       context.stopTEXpage()
>     end
>   \stopluacode
> 
>   Z
> \stoptext
> ----
> 
> Both images of the cow have "BEF2" in the top right corner, but there should be "BEF1" on the former and "BEF2" on the latter.
> 
> I'm trying to pass the text string ("BEF" .. i) via userdata, but it doesn't work.

Afair entire Lua snippet is evaluated first, so any calls to TEX
are delayed until after the loop is executed. Thus the layer is
drawn only when LPr.text already has the final value. But I’m not
entirely sure that’s the correct explanation.

> So how to do it?

Lookup the correct string from a table?

·······································································

\setupbodyfont[30pt]

\starttext
  A

  \definelayer  [beforetext][width=\overlaywidth,height=\overlayheight]
  \defineoverlay[beforetext][{\setups[beforetext]\tightlayer[beforetext]}]

  \startsetups[beforetext]
    \setlayer[beforetext][preset=righttop]
      {\framed[width=2in]{\directlua{userdata.LPr.get_label()}}}
  \stopsetups

  \startluacode
    userdata = userdata or { }
    userdata.LPr = userdata.LPr or { }

    local labels  = { }
    local current = 0

    userdata.LPr.get_label = function ( )
      current = current + 1
      context(labels[current])
    end

    for i = 1, 2 do
      context.startTEXpage { background = "foreground,beforetext" }
        labels[i] = "BEF" .. i
        context.externalfigure({"cow"},{width="30cm"})
      context.stopTEXpage()
    end
  \stopluacode

  Z
\stoptext
·······································································

Regards
Philipp


[-- Attachment #1.2: Type: application/pgp-signature, Size: 198 bytes --]

[-- Attachment #2: Type: text/plain, Size: 485 bytes --]

___________________________________________________________________________________
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
___________________________________________________________________________________

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

* Re: [***Spam/VIR***] Re: Layer vs. overlay
  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
  0 siblings, 1 reply; 16+ messages in thread
From: Procházka Lukáš Ing. - Pontex s. r. o. @ 2013-01-16 13:09 UTC (permalink / raw)
  To: mailing list for ConTeXt users

[-- Attachment #1: Type: text/plain, Size: 1794 bytes --]

Hello,

On Wed, 16 Jan 2013 12:47:21 +0100, Philipp Gesang <philipp.gesang@alumni.uni-heidelberg.de> wrote:

> Lookup the correct string from a table?

thanks for the idea -

- in other words, we have to keep running results somewhere; the algorithm fills a table with texts for each page, and each \setlayer takes one value back, so we can simplify to:

----
\setupbodyfont[30pt]

\starttext
   A

   \definelayer  [beforetext][width=\overlaywidth,height=\overlayheight]
   \defineoverlay[beforetext][{\setups[beforetext]\tightlayer[beforetext]}]

   \startsetups[beforetext]
     \setlayer[beforetext][preset=righttop]
       {\framed[width=2in]{\directlua{context(table.remove(userdata.LPr.texts, 1))}}}
   \stopsetups

   \startluacode
     userdata = userdata or { }
     userdata.LPr = userdata.LPr or { }
     userdata.LPr.texts = {}

     for i = 1, 2 do
       context.startTEXpage { background = "foreground,beforetext" }
         table.insert(userdata.LPr.texts, "BEF" .. i)

         context.externalfigure({"cow"},{width="30cm"})
       context.stopTEXpage()
     end
   \stopluacode

   Z
\stoptext
----

This works.

I'm just thinking whether it would be possible to simplify that all - we're using overlays, layers, setups for overlays and an internal table to keep running results...

BTW: What does \tightlayer[beforetext] exactly do?

Q2: Why some layer properties are specified on \definelayer (beforetext: width=\overlaywidth,height=\overlayheight) and some during overlay setups (beforetext: preset=righttop)?

Lukas


-- 
Ing. Lukáš Procházka [mailto:LPr@pontex.cz]
Pontex s. r. o.      [mailto:pontex@pontex.cz] [http://www.pontex.cz]
Bezová 1658
147 14 Praha 4

Tel: +420 244 062 238
Fax: +420 244 461 038

[-- Attachment #2: Lay9.mkiv --]
[-- Type: application/octet-stream, Size: 763 bytes --]

\setupbodyfont[30pt]

\starttext
  A

  \definelayer  [beforetext][width=\overlaywidth,height=\overlayheight]
  \defineoverlay[beforetext][{\setups[beforetext]\tightlayer[beforetext]}]

  \startsetups[beforetext]
    \setlayer[beforetext][preset=righttop]
      {\framed[width=2in]{\directlua{context(table.remove(userdata.LPr.texts, 1))}}}
  \stopsetups

  \startluacode
    userdata = userdata or { }
    userdata.LPr = userdata.LPr or { }
    userdata.LPr.texts = {}

    for i = 1, 2 do
      context.startTEXpage { background = "foreground,beforetext" }
        table.insert(userdata.LPr.texts, "BEF" .. i)

        context.externalfigure({"cow"},{width="30cm"})
      context.stopTEXpage()
    end
  \stopluacode

  Z
\stoptext

[-- Attachment #3: Lay9.pdf --]
[-- Type: application/pdf, Size: 11093 bytes --]

[-- Attachment #4: Type: text/plain, Size: 485 bytes --]

___________________________________________________________________________________
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
___________________________________________________________________________________

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

* Re: [***Spam/VIR***] Re: Layer vs. overlay
  2013-01-16 13:09                   ` Procházka Lukáš Ing. - Pontex s. r. o.
@ 2013-01-16 13:34                     ` Philipp Gesang
  0 siblings, 0 replies; 16+ messages in thread
From: Philipp Gesang @ 2013-01-16 13:34 UTC (permalink / raw)
  To: mailing list for ConTeXt users


[-- Attachment #1.1: Type: text/plain, Size: 1412 bytes --]

···<date: 2013-01-16, Wednesday>···<from: Procházka Lukáš Ing. - Pontex s. r. o.>···

> Hello,
> 
> On Wed, 16 Jan 2013 12:47:21 +0100, Philipp Gesang <philipp.gesang@alumni.uni-heidelberg.de> wrote:
> 
> >Lookup the correct string from a table?
> 
> thanks for the idea -
> 
> - in other words, we have to keep running results somewhere;

Yes, this is simple because the order of processing doesn’t
change -- as long as the data you aggregate fits into your
memory, of course!

> the algorithm fills a table with texts for each page, and each
> \setlayer takes one value back, so we can simplify to:
> 
</snip>
>     \setlayer[beforetext][preset=righttop]
>       {\framed[width=2in]{\directlua{context(table.remove(userdata.LPr.texts, 1))}}}
</snip>

>       context.startTEXpage { background = "foreground,beforetext" }
>         table.insert(userdata.LPr.texts, "BEF" .. i)
> 
>         context.externalfigure({"cow"},{width="30cm"})
>       context.stopTEXpage()

From my tests calling table.remove() to remove the first element
in a list is extremely inefficient compared to accessing an
array. (For 10^5 elements it’s 1m41.644s vs. 0m0.030s on my
machine.) While we’re at it, table.insert() involves an extra
function call that carries another perfomance penalty, albeit a
much smaller one. Your code should do the same, though.

Regards
Philipp


[-- Attachment #1.2: Type: application/pgp-signature, Size: 198 bytes --]

[-- Attachment #2: Type: text/plain, Size: 485 bytes --]

___________________________________________________________________________________
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
___________________________________________________________________________________

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

end of thread, other threads:[~2013-01-16 13:34 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-01-11 15:32 Layer vs. overlay 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áš
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

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