ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* [NTG-context] Fwd: Re: Working with layer sets with Metapost
@ 2024-02-19 13:28 Emanuel Han via ntg-context
  2024-02-19 13:39 ` [NTG-context] " Mikael Sundqvist
  0 siblings, 1 reply; 3+ messages in thread
From: Emanuel Han via ntg-context @ 2024-02-19 13:28 UTC (permalink / raw)
  To: ntg-context; +Cc: Emanuel Han


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

 I just made a strange observation in the output pdf of the attached layer_set.tex, which is that when opening it with a pdf viewer like skim or macos preview and showing miniatures, all pages except the last one show page number 1 (the last showing page number 2). 

Which was not the case with the output pdf of the attached multipage_metapost_mwe-very_simple.tex. 

How can I change my code to have proper consecutive page numbering in a pdf viewer?
> On Feb. 17 2024, at 11:03 am, Emanuel Han via ntg-context <ntg-context@ntg.nl> wrote:
> I think I could solve all the problems. Attached the finalized working example. I created the https://wiki.contextgarden.net/MetaPost#Layer_sets_as_individual_pages entry with it. Feel free to modify.
> 
> Cheers
> Emanuel
> 
> On Feb. 16 2024, at 7:56 am, Mikael Sundqvist <mickep@gmail.com> wrote:
> Hi,
> 
> not sure I get what you are missing. But you can try
> 
> setbounds currentpicture to (fullsquare scaled 200) ;
> 
> in base. And then do
> 
> \dorecurse{5}{
> \startTEXpage[offset=1DK]
> \useMPgraphic{layerset#1}
> \stopTEXpage
> }
> 
> if that is the looping you are after.
> 
> /Mikael
> 
> On Fri, Feb 16, 2024 at 6:54 AM Emanuel Han via ntg-context
> <ntg-context@ntg.nl> wrote:
> >
> > Resp. the solution should be such that each generated PDF page has the same dimension, the same background colour and a page number and the metapost content on each page has the same scaling factor.
> >
> > On Feb. 15 2024, at 11:10 pm, Emanuel Han via ntg-context <ntg-context@ntg.nl> wrote:
> >
> > Dear Mikael,
> >
> > I actually need to keep the \dorecurse mechanism of the mwe (from line 44 on), because I need the "setbounds currentpicture to TheFrame" and also because I need page numbering inside the MPpage, as done with draw textext(decimal(currentime)).
> >
> > So, how can I use the \useMPgraphic{layerset1} etc. inside the \dorecurse, assuming I name my layersets "layerset1", "layerset2", "layerset3" etc.?
> >
> > Emanuel
> >
> > On Feb. 15 2024, at 10:07 pm, Emanuel Han via ntg-context <ntg-context@ntg.nl> wrote:
> >
> > Dear Mikael,
> > thanks a lot!
> > this seems to be the solution! And it looks beatiful enough to me 😄
> > I'll try to port all my layers to this new method and see if I run into new problems again 😅
> >
> > Emanuel
> >
> >
> > On Feb. 15 2024, at 8:19 am, Mikael Sundqvist <mickep@gmail.com> wrote:
> >
> > Hi
> >
> > On Thu, Feb 15, 2024 at 1:03 AM Emanuel Han via ntg-context
> > <ntg-context@ntg.nl> wrote:
> > >
> > > Dear list,
> > >
> > > the attached .tex file is the minimal working example we discussed today in the online meeting.
> > >
> > > I realized that the approach of looping through k of p[k] is not fitting my needs, because it's not flexible enough.
> > >
> > > I need another approach, one which works with layer sets.
> > >
> > > I would stop using p as an array, because with the layer sets approach we don't have a fixed order of the layers.
> > >
> > > So the definition of the layers would be something like
> > >
> > > picture layerA;
> > > layerA:=image(
> > > label("Word 1", z1);
> > > );
> > >
> > > picture layerW;
> > > layerW:=image(
> > > label("Mot 2", z2);
> > > );
> > >
> > > picture layerM;
> > > layerM:=image(
> > > label("Parola 3", z3);
> > > );
> > >
> > > picture layerC;
> > > layerC:=image(
> > > label("Wort 4", z3+z1);
> > > );
> > >
> > > picture layerY;
> > > layerY:=image(
> > > label("Nummer 5", z2+z3);
> > > );
> > >
> > > picture layerU;
> > > layerU:=image(
> > > label("number 6", z2+z1);
> > > );
> > >
> > > After that, I would define layer sets and layer subsets. This will be done manually for each layer set and each layer subset.
> > > I don't know the proper syntax to do that. Let's assume we could use a variable type called "myset".
> > >
> > > myset layersubsetGamma;
> > > layersubsetGamma:={layerU,layerM};
> > >
> > > In my logic, the layers will be drawn in the order of their appearance within the {}. In the example, drawn content of layerM might cover drawn content of layerU.
> > >
> > > Contrary to a layer subset, each layer set will result in a PDF page, and thus the layer sets are related to each other by an inner order. That's why I would use an array variable here with [].
> > >
> > > I don't know how to append a set. In the following example, I assumed there would be a function myappend(<initial set>, <the things what the initial set should be appended with>)
> > >
> > > myset layerset[];
> > > layerset1 := {layerW,layerA};
> > > layerset2 := myappend{layerset1, layerY};
> > > layerset3 := myappend{layerset2, layersubsetGamma};
> > > layerset4 := myappend{layerset2, layerU};
> > > layerset5 := myappend{layerset4, layersubsetGamma};
> > >
> > > Finally, I would need each layerset[k] typeset on its own pdf page. And of course on each page k, only the layers which appear in the definition of the layerset[k] should be drawn on top of each other in the order as they appear in that definition.
> > >
> > > I'm very curious to hear your suggestions.
> > >
> >
> > Not beautiful, perhaps, but maybe something like this could work? I
> > think there is no way out of doing some manual work to tell what you
> > want included on each page.
> >
> > \startuseMPgraphic{base}
> > z1 = origin ;
> > z2 = (10,50) ;
> > z3 = (40,30) ;
> >
> > picture layerA;
> > layerA:=image(
> > label("Word 1", z1);
> > );
> >
> > picture layerW;
> > layerW:=image(
> > label("Mot 2", z2);
> > );
> >
> > picture layerM;
> > layerM:=image(
> > label("Parola 3", z3);
> > );
> >
> > picture layerC;
> > layerC:=image(
> > label("Wort 4", z3+z1);
> > );
> >
> > picture layerY;
> > layerY:=image(
> > label("Nummer 5", z2+z3);
> > );
> >
> > picture layerU;
> > layerU:=image(
> > label("number 6", z2+z1);
> > );
> > \stopuseMPgraphic
> >
> > \startuseMPgraphic{Gamma}
> > draw layerU ;
> > draw layerM ;
> > \stopuseMPgraphic
> >
> > \startuseMPgraphic{layerset1}
> > \includeMPgraphic{base}
> > draw layerW ;
> > draw layerA ;
> > \stopuseMPgraphic
> >
> > \startuseMPgraphic{layerset2}
> > \includeMPgraphic{layerset1} ;
> > draw layerY ;
> > \stopuseMPgraphic
> >
> > \startuseMPgraphic{layerset3}
> > \includeMPgraphic{layerset2} ;
> > \includeMPgraphic{Gamma} ;
> > \stopuseMPgraphic
> >
> >
> > \startuseMPgraphic{layerset4}
> > \includeMPgraphic{layerset2} ;
> > draw layerU ;
> > \stopuseMPgraphic
> >
> > \startuseMPgraphic{layerset5}
> > \includeMPgraphic{layerset4} ;
> > \includeMPgraphic{Gamma} ;
> > \stopuseMPgraphic
> >
> > \starttext
> >
> > \startTEXpage[offset=1DK]
> > \useMPgraphic{layerset1}
> > \stopTEXpage
> >
> > \startTEXpage[offset=1DK]
> > \useMPgraphic{layerset2}
> > \stopTEXpage
> >
> > \startTEXpage[offset=1DK]
> > \useMPgraphic{layerset3}
> > \stopTEXpage
> >
> > \startTEXpage[offset=1DK]
> > \useMPgraphic{layerset4}
> > \stopTEXpage
> >
> > \startTEXpage[offset=1DK]
> > \useMPgraphic{layerset5}
> > \stopTEXpage
> >
> > \stoptext
> >
> > /Mikael
> > ___________________________________________________________________________________
> > If your question is of interest to others as well, please add an entry to the Wiki!
> >
> > maillist : ntg-context@ntg.nl / https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl
> > webpage : https://www.pragma-ade.nl / https://context.aanhet.net (mirror)
> > archive : https://github.com/contextgarden/context
> > wiki : https://wiki.contextgarden.net
> > ___________________________________________________________________________________
> >
> > ___________________________________________________________________________________
> > If your question is of interest to others as well, please add an entry to the Wiki!
> >
> > maillist : ntg-context@ntg.nl / https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl
> > webpage : https://www.pragma-ade.nl / https://context.aanhet.net (mirror)
> > archive : https://github.com/contextgarden/context
> > wiki : https://wiki.contextgarden.net
> > ___________________________________________________________________________________
> >
> > ___________________________________________________________________________________
> > If your question is of interest to others as well, please add an entry to the Wiki!
> >
> > maillist : ntg-context@ntg.nl / https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl
> > webpage : https://www.pragma-ade.nl / https://context.aanhet.net (mirror)
> > archive : https://github.com/contextgarden/context
> > wiki : https://wiki.contextgarden.net
> > ___________________________________________________________________________________
> >
> > ___________________________________________________________________________________
> > If your question is of interest to others as well, please add an entry to the Wiki!
> >
> > maillist : ntg-context@ntg.nl / https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl
> > webpage : https://www.pragma-ade.nl / https://context.aanhet.net (mirror)
> > archive : https://github.com/contextgarden/context
> > wiki : https://wiki.contextgarden.net
> > ___________________________________________________________________________________
> ___________________________________________________________________________________
> If your question is of interest to others as well, please add an entry to the Wiki!
> 
> maillist : ntg-context@ntg.nl / https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl
> webpage : https://www.pragma-ade.nl / https://context.aanhet.net (mirror)
> archive : https://github.com/contextgarden/context
> wiki : https://wiki.contextgarden.net
> ___________________________________________________________________________________
> ___________________________________________________________________________________
> If your question is of interest to others as well, please add an entry to the Wiki!
> 
> maillist : ntg-context@ntg.nl / https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl
> webpage : https://www.pragma-ade.nl / https://context.aanhet.net (mirror)
> archive : https://github.com/contextgarden/context
> wiki : https://wiki.contextgarden.net
> ___________________________________________________________________________________


[-- Attachment #1.2.1: Type: text/html, Size: 14395 bytes --]

[-- Attachment #1.2.2: multipage_metapost_mwe-very_simple.tex --]
[-- Type: application/octet-stream, Size: 1814 bytes --]

% !TEX TS-program = ConTeXt2021

\startuseMPgraphic{base}
    picture p[];
    path TheFrame ;
    TheFrame := fullsquare scaled 5in ;
    
    %let's define the commonly used geometry elements
    
    z1 = (60,40);
    z2 = (40,90);
    z3 = (10,70);
    
    %let's define some layers with drawn content

    p1:=image(
    label("Word 1", z1);
    );

    p2:=image(
    label("Mot 2", z2);
    );

    p3:=image(
    label("Parola 3", z3);
    );
    
    p4:=image(
    label("Wort 4", z3+z1);
    );

    p5:=image(
    label("Nummer 5", z2+z3);
    );
    
    p6:=image(
    label("number 6", z2+z1);
    );

    \stopuseMPgraphic

    \starttext

    \dorecurse{6}{ % Frame
	\ifnum 
            \recurselevel = 3 %this defines the page which will be skipped. This solution allows only one page to be skipped. 
	\else
            \startMPpage[pagestate=start]
        
            \includeMPgraphic{base}
        
            currentime := #1 ;
            % Just for learning :
            draw TheFrame withpen pencircle scaled .1in withcolor magenta ;
            draw textext("T="&decimal(currentime)) shifted(0,2in)
            withcolor magenta ;
            boolean b[]; 
            %in the following lines b[] := , we define the images which should not be added to currentpicture:
            b[3] := true; 
            b[5] := true;
            for k=1 upto currentime: 
            if known b[k] :
            else :
            addto currentpicture also p[k]; 
            fi
            endfor
            setbounds currentpicture to TheFrame ;
        
            desiredformat := 1080;% In pixels (will be converted by default at 72dpi)
            currentpicture := currentpicture xysized (desiredformat ,desiredformat );
        
            \stopMPpage
        \fi
    }

    \stoptext

[-- Attachment #1.2.3: Type: text/html, Size: 315 bytes --]

[-- Attachment #1.2.4: layer_sets.tex --]
[-- Type: application/octet-stream, Size: 4797 bytes --]

% !TEX TS-program = ConTeXt2021

\startuseMPgraphic{base} %Here in the base, we define the components we will use to draw our images
numeric u; u = 1cm; 
numeric framefactor; framefactor = 3.4;
path TheFrame ; TheFrame := fullsquare xyscaled (framefactor*u, framefactor*u)  ; %Needed to have for every page the same dimensions. Use (sqrt(2)*framefactor*u, framefactor*u) for DIN A Landscape ratio of the dimensions. 
color stone_color; stone_color = 1/256(199,199,199);
color light_teal_color; light_teal_color = 1/256(154,209,189);

z1 = (-u,-u) ;
z2 = (u,-u) ;
z3 = (-u,u) ;
z4 = (u,u) ;
z5 = (-.5u,0);
z6 = (.8u,0);

picture layerA;
layerA:=image(
fill fullsquare scaled u shifted(z1) withcolor stone_color;
label("A", z1);
);

picture layerW;
layerW:=image(
fill fullsquare scaled u shifted(z2) withcolor stone_color;
label("W", z2);
);

picture layerM;
layerM:=image(
fill fullsquare scaled u shifted(z3) withcolor blue;
label("M", z3) withcolor white;
);

picture layerC;
layerC:=image(
fill fullsquare scaled 1.5u shifted(z4) withcolor  transparent(1, .8, green);
label("C", z4);
);

picture layerY;
layerY:=image(
fill fullsquare scaled 2u shifted(z5) withcolor light_teal_color;
label("Y", z5);
);

picture layerU;
layerU:=image(
fill fullsquare rotated 30 scaled 2u shifted(z4) withcolor transparent(1, .5, red);
label("U", z4);
);

picture layerV;
layerV:=image(
fill fullsquare rotated 10 scaled 1.4u shifted(z6) withcolor transparent(1, .7, yellow);
label("V", z6);
);
\stopuseMPgraphic %base

\startuseMPgraphic{finishing} %This is needed to clip the graphic to the same frame and to add the page numbering. Both have to happen after drawing the layers. 
draw TheFrame withpen pencircle scaled .25u withcolor magenta ;
draw textext(decimal(\MPvar{mypagenumber})) scaled .1u withcolor magenta ;
setbounds currentpicture to TheFrame ;
%scaling the page to your preferred dimension: 
desiredformat := 150;% In pixels (will be converted by default at 72dpi). The shorter dimension of DIN A4 would be 595 pixels. 
currentpicture := currentpicture xysized (desiredformat ,desiredformat ); %for square pages. If DIN A Landscape, use  (sqrt(2)*desiredformat ,desiredformat)
\stopuseMPgraphic %finishing

\startuseMPgraphic{Gamma} %This is a layer subset which will be used more than once. I call it a layer subset and not a layer set because it doesn't include another MPgraphic.
draw layerU ;
draw layerM ;
\stopuseMPgraphic %Gamma

\startuseMPgraphic{layersetpage1} %Each layersetpage will become a page containing the defined layer set. The number corresponds to the page number. Start with number 1. 
\includeMPgraphic{base} %base has to be included only in layersetpage1. It will be passed on to the next layersetpages via inclusion. 
draw layerW ;
draw layerA ;
\stopuseMPgraphic

\startuseMPgraphic{layersetpage2} %There should be no gap in the sequence of the numbers of the layersetpages
\includeMPgraphic{layersetpage1} ;
draw layerV ;
\stopuseMPgraphic

\startuseMPgraphic{layersetpage3}
\includeMPgraphic{layersetpage2} ;
\includeMPgraphic{Gamma} ;
\stopuseMPgraphic 

\startuseMPgraphic{layersetpre4} %This is a layer set because it includes another MPgraphic. It will be used more than once, but it will not become a page itself. It's only an intermediate step on the way to the next layersetpage. For that reason, it's not named layersetpage. Because it's coming before the layersetpage4, I call it layersetpre4. If I need another intermediate step stored before layersetpre4, I would call it layersetprepre4. But that's only a naming convention for myself.
\includeMPgraphic{layersetpage1} ;
draw layerY ;
\stopuseMPgraphic 

\startuseMPgraphic{layersetpage4}
\includeMPgraphic{layersetpre4} ;
label("special!", (z3+z4)/2) rotated 5 withcolor red;
\stopuseMPgraphic



\startuseMPgraphic{layersetpage5}
\includeMPgraphic{layersetpage3} ;
draw layerC ;
\stopuseMPgraphic

\startuseMPgraphic{layersetpage6}
\includeMPgraphic{layersetpre4} ;
draw layerC ;
\stopuseMPgraphic

\starttext

\dorecurse{6}{ %This loop starts from 1 until the set number and draws each layersetpage onto its own page. Don't set a number which is higher than the number of your last layersetpage.

%By differentiating finishinglayersetpage#1 from layersetpage#1, we can avoid adding \includeMPgraphic{finishing} to each \startuseMPgraphic{layersetpage<number>}. This allows us to apply the scaling of the page to our desiredformat, because the scaling will done only once per \useMPgraphic{}.
\startuseMPgraphic{finishinglayersetpage#1}
\includeMPgraphic{layersetpage#1} ;
\includeMPgraphic{finishing}
\stopuseMPgraphic

%uncomment if needed: 
% \setupTEXpage[background=color, backgroundcolor=gray]
  \startTEXpage
    \useMPgraphic{finishinglayersetpage#1}{mypagenumber=#1}
  \stopTEXpage
}
\stoptext

[-- Attachment #1.2.5: Type: text/html, Size: 401 bytes --]

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

___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl
webpage  : https://www.pragma-ade.nl / https://context.aanhet.net (mirror)
archive  : https://github.com/contextgarden/context
wiki     : https://wiki.contextgarden.net
___________________________________________________________________________________

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

* [NTG-context] Re: Fwd: Re: Working with layer sets with Metapost
  2024-02-19 13:28 [NTG-context] Fwd: Re: Working with layer sets with Metapost Emanuel Han via ntg-context
@ 2024-02-19 13:39 ` Mikael Sundqvist
  2024-02-19 18:46   ` Emanuel Han via ntg-context
  0 siblings, 1 reply; 3+ messages in thread
From: Mikael Sundqvist @ 2024-02-19 13:39 UTC (permalink / raw)
  To: mailing list for ConTeXt users

Hi,

Try

\startTEXpage[pagestate=start]

/Mikael

On Mon, Feb 19, 2024 at 2:31 PM Emanuel Han via ntg-context
<ntg-context@ntg.nl> wrote:
>
>  I just made a strange observation in the output pdf of the attached layer_set.tex, which is that when opening it with a pdf viewer like skim or macos preview and showing miniatures, all pages except the last one show page number 1 (the last showing page number 2).
>
> Which was not the case with the output pdf of the attached multipage_metapost_mwe-very_simple.tex.
>
> How can I change my code to have proper consecutive page numbering in a pdf viewer?
>
> On Feb. 17 2024, at 11:03 am, Emanuel Han via ntg-context <ntg-context@ntg.nl> wrote:
>
> I think I could solve all the problems. Attached the finalized working example. I created the https://wiki.contextgarden.net/MetaPost#Layer_sets_as_individual_pages entry with it. Feel free to modify.
>
> Cheers
> Emanuel
>
> On Feb. 16 2024, at 7:56 am, Mikael Sundqvist <mickep@gmail.com> wrote:
>
> Hi,
>
> not sure I get what you are missing. But you can try
>
> setbounds currentpicture to (fullsquare scaled 200) ;
>
> in base. And then do
>
> \dorecurse{5}{
> \startTEXpage[offset=1DK]
> \useMPgraphic{layerset#1}
> \stopTEXpage
> }
>
> if that is the looping you are after.
>
> /Mikael
>
> On Fri, Feb 16, 2024 at 6:54 AM Emanuel Han via ntg-context
> <ntg-context@ntg.nl> wrote:
> >
> > Resp. the solution should be such that each generated PDF page has the same dimension, the same background colour and a page number and the metapost content on each page has the same scaling factor.
> >
> > On Feb. 15 2024, at 11:10 pm, Emanuel Han via ntg-context <ntg-context@ntg.nl> wrote:
> >
> > Dear Mikael,
> >
> > I actually need to keep the \dorecurse mechanism of the mwe (from line 44 on), because I need the "setbounds currentpicture to TheFrame" and also because I need page numbering inside the MPpage, as done with draw textext(decimal(currentime)).
> >
> > So, how can I use the \useMPgraphic{layerset1} etc. inside the \dorecurse, assuming I name my layersets "layerset1", "layerset2", "layerset3" etc.?
> >
> > Emanuel
> >
> > On Feb. 15 2024, at 10:07 pm, Emanuel Han via ntg-context <ntg-context@ntg.nl> wrote:
> >
> > Dear Mikael,
> > thanks a lot!
> > this seems to be the solution! And it looks beatiful enough to me 😄
> > I'll try to port all my layers to this new method and see if I run into new problems again 😅
> >
> > Emanuel
> >
> >
> > On Feb. 15 2024, at 8:19 am, Mikael Sundqvist <mickep@gmail.com> wrote:
> >
> > Hi
> >
> > On Thu, Feb 15, 2024 at 1:03 AM Emanuel Han via ntg-context
> > <ntg-context@ntg.nl> wrote:
> > >
> > > Dear list,
> > >
> > > the attached .tex file is the minimal working example we discussed today in the online meeting.
> > >
> > > I realized that the approach of looping through k of p[k] is not fitting my needs, because it's not flexible enough.
> > >
> > > I need another approach, one which works with layer sets.
> > >
> > > I would stop using p as an array, because with the layer sets approach we don't have a fixed order of the layers.
> > >
> > > So the definition of the layers would be something like
> > >
> > > picture layerA;
> > > layerA:=image(
> > > label("Word 1", z1);
> > > );
> > >
> > > picture layerW;
> > > layerW:=image(
> > > label("Mot 2", z2);
> > > );
> > >
> > > picture layerM;
> > > layerM:=image(
> > > label("Parola 3", z3);
> > > );
> > >
> > > picture layerC;
> > > layerC:=image(
> > > label("Wort 4", z3+z1);
> > > );
> > >
> > > picture layerY;
> > > layerY:=image(
> > > label("Nummer 5", z2+z3);
> > > );
> > >
> > > picture layerU;
> > > layerU:=image(
> > > label("number 6", z2+z1);
> > > );
> > >
> > > After that, I would define layer sets and layer subsets. This will be done manually for each layer set and each layer subset.
> > > I don't know the proper syntax to do that. Let's assume we could use a variable type called "myset".
> > >
> > > myset layersubsetGamma;
> > > layersubsetGamma:={layerU,layerM};
> > >
> > > In my logic, the layers will be drawn in the order of their appearance within the {}. In the example, drawn content of layerM might cover drawn content of layerU.
> > >
> > > Contrary to a layer subset, each layer set will result in a PDF page, and thus the layer sets are related to each other by an inner order. That's why I would use an array variable here with [].
> > >
> > > I don't know how to append a set. In the following example, I assumed there would be a function myappend(<initial set>, <the things what the initial set should be appended with>)
> > >
> > > myset layerset[];
> > > layerset1 := {layerW,layerA};
> > > layerset2 := myappend{layerset1, layerY};
> > > layerset3 := myappend{layerset2, layersubsetGamma};
> > > layerset4 := myappend{layerset2, layerU};
> > > layerset5 := myappend{layerset4, layersubsetGamma};
> > >
> > > Finally, I would need each layerset[k] typeset on its own pdf page. And of course on each page k, only the layers which appear in the definition of the layerset[k] should be drawn on top of each other in the order as they appear in that definition.
> > >
> > > I'm very curious to hear your suggestions.
> > >
> >
> > Not beautiful, perhaps, but maybe something like this could work? I
> > think there is no way out of doing some manual work to tell what you
> > want included on each page.
> >
> > \startuseMPgraphic{base}
> > z1 = origin ;
> > z2 = (10,50) ;
> > z3 = (40,30) ;
> >
> > picture layerA;
> > layerA:=image(
> > label("Word 1", z1);
> > );
> >
> > picture layerW;
> > layerW:=image(
> > label("Mot 2", z2);
> > );
> >
> > picture layerM;
> > layerM:=image(
> > label("Parola 3", z3);
> > );
> >
> > picture layerC;
> > layerC:=image(
> > label("Wort 4", z3+z1);
> > );
> >
> > picture layerY;
> > layerY:=image(
> > label("Nummer 5", z2+z3);
> > );
> >
> > picture layerU;
> > layerU:=image(
> > label("number 6", z2+z1);
> > );
> > \stopuseMPgraphic
> >
> > \startuseMPgraphic{Gamma}
> > draw layerU ;
> > draw layerM ;
> > \stopuseMPgraphic
> >
> > \startuseMPgraphic{layerset1}
> > \includeMPgraphic{base}
> > draw layerW ;
> > draw layerA ;
> > \stopuseMPgraphic
> >
> > \startuseMPgraphic{layerset2}
> > \includeMPgraphic{layerset1} ;
> > draw layerY ;
> > \stopuseMPgraphic
> >
> > \startuseMPgraphic{layerset3}
> > \includeMPgraphic{layerset2} ;
> > \includeMPgraphic{Gamma} ;
> > \stopuseMPgraphic
> >
> >
> > \startuseMPgraphic{layerset4}
> > \includeMPgraphic{layerset2} ;
> > draw layerU ;
> > \stopuseMPgraphic
> >
> > \startuseMPgraphic{layerset5}
> > \includeMPgraphic{layerset4} ;
> > \includeMPgraphic{Gamma} ;
> > \stopuseMPgraphic
> >
> > \starttext
> >
> > \startTEXpage[offset=1DK]
> > \useMPgraphic{layerset1}
> > \stopTEXpage
> >
> > \startTEXpage[offset=1DK]
> > \useMPgraphic{layerset2}
> > \stopTEXpage
> >
> > \startTEXpage[offset=1DK]
> > \useMPgraphic{layerset3}
> > \stopTEXpage
> >
> > \startTEXpage[offset=1DK]
> > \useMPgraphic{layerset4}
> > \stopTEXpage
> >
> > \startTEXpage[offset=1DK]
> > \useMPgraphic{layerset5}
> > \stopTEXpage
> >
> > \stoptext
> >
> > /Mikael
> > ___________________________________________________________________________________
> > If your question is of interest to others as well, please add an entry to the Wiki!
> >
> > maillist : ntg-context@ntg.nl / https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl
> > webpage : https://www.pragma-ade.nl / https://context.aanhet.net (mirror)
> > archive : https://github.com/contextgarden/context
> > wiki : https://wiki.contextgarden.net
> > ___________________________________________________________________________________
> >
> > ___________________________________________________________________________________
> > If your question is of interest to others as well, please add an entry to the Wiki!
> >
> > maillist : ntg-context@ntg.nl / https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl
> > webpage : https://www.pragma-ade.nl / https://context.aanhet.net (mirror)
> > archive : https://github.com/contextgarden/context
> > wiki : https://wiki.contextgarden.net
> > ___________________________________________________________________________________
> >
> > ___________________________________________________________________________________
> > If your question is of interest to others as well, please add an entry to the Wiki!
> >
> > maillist : ntg-context@ntg.nl / https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl
> > webpage : https://www.pragma-ade.nl / https://context.aanhet.net (mirror)
> > archive : https://github.com/contextgarden/context
> > wiki : https://wiki.contextgarden.net
> > ___________________________________________________________________________________
> >
> > ___________________________________________________________________________________
> > If your question is of interest to others as well, please add an entry to the Wiki!
> >
> > maillist : ntg-context@ntg.nl / https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl
> > webpage : https://www.pragma-ade.nl / https://context.aanhet.net (mirror)
> > archive : https://github.com/contextgarden/context
> > wiki : https://wiki.contextgarden.net
> > ___________________________________________________________________________________
> ___________________________________________________________________________________
> If your question is of interest to others as well, please add an entry to the Wiki!
>
> maillist : ntg-context@ntg.nl / https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl
> webpage : https://www.pragma-ade.nl / https://context.aanhet.net (mirror)
> archive : https://github.com/contextgarden/context
> wiki : https://wiki.contextgarden.net
> ___________________________________________________________________________________
>
> ___________________________________________________________________________________
> If your question is of interest to others as well, please add an entry to the Wiki!
>
> maillist : ntg-context@ntg.nl / https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl
> webpage : https://www.pragma-ade.nl / https://context.aanhet.net (mirror)
> archive : https://github.com/contextgarden/context
> wiki : https://wiki.contextgarden.net
> ___________________________________________________________________________________
>
>
> ___________________________________________________________________________________
> If your question is of interest to others as well, please add an entry to the Wiki!
>
> maillist : ntg-context@ntg.nl / https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl
> webpage  : https://www.pragma-ade.nl / https://context.aanhet.net (mirror)
> archive  : https://github.com/contextgarden/context
> wiki     : https://wiki.contextgarden.net
> ___________________________________________________________________________________
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl
webpage  : https://www.pragma-ade.nl / https://context.aanhet.net (mirror)
archive  : https://github.com/contextgarden/context
wiki     : https://wiki.contextgarden.net
___________________________________________________________________________________

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

* [NTG-context] Re: Fwd: Re: Working with layer sets with Metapost
  2024-02-19 13:39 ` [NTG-context] " Mikael Sundqvist
@ 2024-02-19 18:46   ` Emanuel Han via ntg-context
  0 siblings, 0 replies; 3+ messages in thread
From: Emanuel Han via ntg-context @ 2024-02-19 18:46 UTC (permalink / raw)
  To: mailing list for ConTeXt users; +Cc: Emanuel Han


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

Thanks Mikael. This helped indeed.
I updated my example on the Metapost page in the wiki accordingly.

The`pagestate=start` functionality is not documented in the wiki. It's not clear for which context commands it can or should be used. Who is willing to help out here?
Best regards
Emanuel
On Feb. 19 2024, at 2:39 pm, Mikael Sundqvist <mickep@gmail.com> wrote:
> Hi,
>
> Try
> \startTEXpage[pagestate=start]
> /Mikael
> On Mon, Feb 19, 2024 at 2:31 PM Emanuel Han via ntg-context
> <ntg-context@ntg.nl> wrote:
> >
> >  I just made a strange observation in the output pdf of the attached layer_set.tex, which is that when opening it with a pdf viewer like skim or macos preview and showing miniatures, all pages except the last one show page number 1 (the last showing page number 2).
> >
> > Which was not the case with the output pdf of the attached multipage_metapost_mwe-very_simple.tex.
> >
> > How can I change my code to have proper consecutive page numbering in a pdf viewer?
> >
> > On Feb. 17 2024, at 11:03 am, Emanuel Han via ntg-context <ntg-context@ntg.nl> wrote:
> >
> > I think I could solve all the problems. Attached the finalized working example. I created the https://wiki.contextgarden.net/MetaPost#Layer_sets_as_individual_pages entry with it. Feel free to modify.
> >
> > Cheers
> > Emanuel
> >
> > On Feb. 16 2024, at 7:56 am, Mikael Sundqvist <mickep@gmail.com> wrote:
> >
> > Hi,
> >
> > not sure I get what you are missing. But you can try
> >
> > setbounds currentpicture to (fullsquare scaled 200) ;
> >
> > in base. And then do
> >
> > \dorecurse{5}{
> > \startTEXpage[offset=1DK]
> > \useMPgraphic{layerset#1}
> > \stopTEXpage
> > }
> >
> > if that is the looping you are after.
> >
> > /Mikael
> >
> > On Fri, Feb 16, 2024 at 6:54 AM Emanuel Han via ntg-context
> > <ntg-context@ntg.nl> wrote:
> > >
> > > Resp. the solution should be such that each generated PDF page has the same dimension, the same background colour and a page number and the metapost content on each page has the same scaling factor.
> > >
> > > On Feb. 15 2024, at 11:10 pm, Emanuel Han via ntg-context <ntg-context@ntg.nl> wrote:
> > >
> > > Dear Mikael,
> > >
> > > I actually need to keep the \dorecurse mechanism of the mwe (from line 44 on), because I need the "setbounds currentpicture to TheFrame" and also because I need page numbering inside the MPpage, as done with draw textext(decimal(currentime)).
> > >
> > > So, how can I use the \useMPgraphic{layerset1} etc. inside the \dorecurse, assuming I name my layersets "layerset1", "layerset2", "layerset3" etc.?
> > >
> > > Emanuel
> > >
> > > On Feb. 15 2024, at 10:07 pm, Emanuel Han via ntg-context <ntg-context@ntg.nl> wrote:
> > >
> > > Dear Mikael,
> > > thanks a lot!
> > > this seems to be the solution! And it looks beatiful enough to me 😄
> > > I'll try to port all my layers to this new method and see if I run into new problems again 😅
> > >
> > > Emanuel
> > >
> > >
> > > On Feb. 15 2024, at 8:19 am, Mikael Sundqvist <mickep@gmail.com> wrote:
> > >
> > > Hi
> > >
> > > On Thu, Feb 15, 2024 at 1:03 AM Emanuel Han via ntg-context
> > > <ntg-context@ntg.nl> wrote:
> > > >
> > > > Dear list,
> > > >
> > > > the attached .tex file is the minimal working example we discussed today in the online meeting.
> > > >
> > > > I realized that the approach of looping through k of p[k] is not fitting my needs, because it's not flexible enough.
> > > >
> > > > I need another approach, one which works with layer sets.
> > > >
> > > > I would stop using p as an array, because with the layer sets approach we don't have a fixed order of the layers.
> > > >
> > > > So the definition of the layers would be something like
> > > >
> > > > picture layerA;
> > > > layerA:=image(
> > > > label("Word 1", z1);
> > > > );
> > > >
> > > > picture layerW;
> > > > layerW:=image(
> > > > label("Mot 2", z2);
> > > > );
> > > >
> > > > picture layerM;
> > > > layerM:=image(
> > > > label("Parola 3", z3);
> > > > );
> > > >
> > > > picture layerC;
> > > > layerC:=image(
> > > > label("Wort 4", z3+z1);
> > > > );
> > > >
> > > > picture layerY;
> > > > layerY:=image(
> > > > label("Nummer 5", z2+z3);
> > > > );
> > > >
> > > > picture layerU;
> > > > layerU:=image(
> > > > label("number 6", z2+z1);
> > > > );
> > > >
> > > > After that, I would define layer sets and layer subsets. This will be done manually for each layer set and each layer subset.
> > > > I don't know the proper syntax to do that. Let's assume we could use a variable type called "myset".
> > > >
> > > > myset layersubsetGamma;
> > > > layersubsetGamma:={layerU,layerM};
> > > >
> > > > In my logic, the layers will be drawn in the order of their appearance within the {}. In the example, drawn content of layerM might cover drawn content of layerU.
> > > >
> > > > Contrary to a layer subset, each layer set will result in a PDF page, and thus the layer sets are related to each other by an inner order. That's why I would use an array variable here with [].
> > > >
> > > > I don't know how to append a set. In the following example, I assumed there would be a function myappend(<initial set>, <the things what the initial set should be appended with>)
> > > >
> > > > myset layerset[];
> > > > layerset1 := {layerW,layerA};
> > > > layerset2 := myappend{layerset1, layerY};
> > > > layerset3 := myappend{layerset2, layersubsetGamma};
> > > > layerset4 := myappend{layerset2, layerU};
> > > > layerset5 := myappend{layerset4, layersubsetGamma};
> > > >
> > > > Finally, I would need each layerset[k] typeset on its own pdf page. And of course on each page k, only the layers which appear in the definition of the layerset[k] should be drawn on top of each other in the order as they appear in that definition.
> > > >
> > > > I'm very curious to hear your suggestions.
> > > >
> > >
> > > Not beautiful, perhaps, but maybe something like this could work? I
> > > think there is no way out of doing some manual work to tell what you
> > > want included on each page.
> > >
> > > \startuseMPgraphic{base}
> > > z1 = origin ;
> > > z2 = (10,50) ;
> > > z3 = (40,30) ;
> > >
> > > picture layerA;
> > > layerA:=image(
> > > label("Word 1", z1);
> > > );
> > >
> > > picture layerW;
> > > layerW:=image(
> > > label("Mot 2", z2);
> > > );
> > >
> > > picture layerM;
> > > layerM:=image(
> > > label("Parola 3", z3);
> > > );
> > >
> > > picture layerC;
> > > layerC:=image(
> > > label("Wort 4", z3+z1);
> > > );
> > >
> > > picture layerY;
> > > layerY:=image(
> > > label("Nummer 5", z2+z3);
> > > );
> > >
> > > picture layerU;
> > > layerU:=image(
> > > label("number 6", z2+z1);
> > > );
> > > \stopuseMPgraphic
> > >
> > > \startuseMPgraphic{Gamma}
> > > draw layerU ;
> > > draw layerM ;
> > > \stopuseMPgraphic
> > >
> > > \startuseMPgraphic{layerset1}
> > > \includeMPgraphic{base}
> > > draw layerW ;
> > > draw layerA ;
> > > \stopuseMPgraphic
> > >
> > > \startuseMPgraphic{layerset2}
> > > \includeMPgraphic{layerset1} ;
> > > draw layerY ;
> > > \stopuseMPgraphic
> > >
> > > \startuseMPgraphic{layerset3}
> > > \includeMPgraphic{layerset2} ;
> > > \includeMPgraphic{Gamma} ;
> > > \stopuseMPgraphic
> > >
> > >
> > > \startuseMPgraphic{layerset4}
> > > \includeMPgraphic{layerset2} ;
> > > draw layerU ;
> > > \stopuseMPgraphic
> > >
> > > \startuseMPgraphic{layerset5}
> > > \includeMPgraphic{layerset4} ;
> > > \includeMPgraphic{Gamma} ;
> > > \stopuseMPgraphic
> > >
> > > \starttext
> > >
> > > \startTEXpage[offset=1DK]
> > > \useMPgraphic{layerset1}
> > > \stopTEXpage
> > >
> > > \startTEXpage[offset=1DK]
> > > \useMPgraphic{layerset2}
> > > \stopTEXpage
> > >
> > > \startTEXpage[offset=1DK]
> > > \useMPgraphic{layerset3}
> > > \stopTEXpage
> > >
> > > \startTEXpage[offset=1DK]
> > > \useMPgraphic{layerset4}
> > > \stopTEXpage
> > >
> > > \startTEXpage[offset=1DK]
> > > \useMPgraphic{layerset5}
> > > \stopTEXpage
> > >
> > > \stoptext
> > >
> > > /Mikael
> > > ___________________________________________________________________________________
> > > If your question is of interest to others as well, please add an entry to the Wiki!
> > >
> > > maillist : ntg-context@ntg.nl / https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl
> > > webpage : https://www.pragma-ade.nl / https://context.aanhet.net (mirror)
> > > archive : https://github.com/contextgarden/context
> > > wiki : https://wiki.contextgarden.net
> > > ___________________________________________________________________________________
> > >
> > > ___________________________________________________________________________________
> > > If your question is of interest to others as well, please add an entry to the Wiki!
> > >
> > > maillist : ntg-context@ntg.nl / https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl
> > > webpage : https://www.pragma-ade.nl / https://context.aanhet.net (mirror)
> > > archive : https://github.com/contextgarden/context
> > > wiki : https://wiki.contextgarden.net
> > > ___________________________________________________________________________________
> > >
> > > ___________________________________________________________________________________
> > > If your question is of interest to others as well, please add an entry to the Wiki!
> > >
> > > maillist : ntg-context@ntg.nl / https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl
> > > webpage : https://www.pragma-ade.nl / https://context.aanhet.net (mirror)
> > > archive : https://github.com/contextgarden/context
> > > wiki : https://wiki.contextgarden.net
> > > ___________________________________________________________________________________
> > >
> > > ___________________________________________________________________________________
> > > If your question is of interest to others as well, please add an entry to the Wiki!
> > >
> > > maillist : ntg-context@ntg.nl / https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl
> > > webpage : https://www.pragma-ade.nl / https://context.aanhet.net (mirror)
> > > archive : https://github.com/contextgarden/context
> > > wiki : https://wiki.contextgarden.net
> > > ___________________________________________________________________________________
> > ___________________________________________________________________________________
> > If your question is of interest to others as well, please add an entry to the Wiki!
> >
> > maillist : ntg-context@ntg.nl / https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl
> > webpage : https://www.pragma-ade.nl / https://context.aanhet.net (mirror)
> > archive : https://github.com/contextgarden/context
> > wiki : https://wiki.contextgarden.net
> > ___________________________________________________________________________________
> >
> > ___________________________________________________________________________________
> > If your question is of interest to others as well, please add an entry to the Wiki!
> >
> > maillist : ntg-context@ntg.nl / https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl
> > webpage : https://www.pragma-ade.nl / https://context.aanhet.net (mirror)
> > archive : https://github.com/contextgarden/context
> > wiki : https://wiki.contextgarden.net
> > ___________________________________________________________________________________
> >
> >
> > ___________________________________________________________________________________
> > If your question is of interest to others as well, please add an entry to the Wiki!
> >
> > maillist : ntg-context@ntg.nl / https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl
> > webpage : https://www.pragma-ade.nl / https://context.aanhet.net (mirror)
> > archive : https://github.com/contextgarden/context
> > wiki : https://wiki.contextgarden.net
> > ___________________________________________________________________________________
> ___________________________________________________________________________________
> If your question is of interest to others as well, please add an entry to the Wiki!
>
> maillist : ntg-context@ntg.nl / https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl
> webpage : https://www.pragma-ade.nl / https://context.aanhet.net (mirror)
> archive : https://github.com/contextgarden/context
> wiki : https://wiki.contextgarden.net
> ___________________________________________________________________________________
>


[-- Attachment #1.2: Type: text/html, Size: 16715 bytes --]

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

___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl
webpage  : https://www.pragma-ade.nl / https://context.aanhet.net (mirror)
archive  : https://github.com/contextgarden/context
wiki     : https://wiki.contextgarden.net
___________________________________________________________________________________

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

end of thread, other threads:[~2024-02-19 18:52 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-02-19 13:28 [NTG-context] Fwd: Re: Working with layer sets with Metapost Emanuel Han via ntg-context
2024-02-19 13:39 ` [NTG-context] " Mikael Sundqvist
2024-02-19 18:46   ` Emanuel Han via ntg-context

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