Fielstack and Layers for Presentation
Hi all, I would use fieldstack with \getbuffer and overlays... Why the following code doesn't work ? Is there another way to do that ? TIA Renaud %%%%%%% stack.tex \setupcolors[state=start] \usemodule[pre-original] \defineoverlay[FunnyFrame][\useMPgraphic{FunnyFrame}] \defineframedtext[FunnyText][frame=off,background=FunnyFrame] \def\StartFrame{\startFunnyText} \def\StopFrame {\stopFunnyText } \def\FrameTitle#1% {\setMPtext{FunnyFrame}{\hbox spread 1em{\hss\strut#1\hss}}} \setMPtext{FunnyFrame}{} % initialize the text variable \startuseMPgraphic{FunnyFrame} picture p ; numeric o ; path a, b ; pair c ; p := textext.rt(\MPstring{FunnyFrame}) ; a := unitsquare xyscaled(OverlayWidth,OverlayHeight) ; o := BodyFontSize ; p := p shifted (2o,OverlayHeight-ypart center p) ; drawoptions (withpen pencircle scaled 1pt withcolor .625red) ; b := a randomized (o/2) ; fill b withcolor .85white ; draw b ; c := center p ; c := b intersectionpoint (c shifted (0,-o)--c shifted(0,o)) ; p := p shifted (c-center p) ; b := (boundingbox p) randomized (o/8) ; fill b withcolor .85white ; draw b ; draw p withcolor black; setbounds currentpicture to a ; \stopuseMPgraphic \definelayer[bglayer][position=yes] \setupbackgrounds[text][background=bglayer] \setuplayer[bglayer][position=no,corner=bottom,height=\paperheight] \starttext \startbuffer[first] \setlayer[bglayer][x=.55\textwidth,y=.9\textheight,location=b]{ \FrameTitle{Knuth} \StartFrame[width=.75\textwidth] \input knuth \StopFrame } \stopbuffer \startbuffer[second] \setlayer[bglayer][x=.625\textwidth,y=.8\textheight,location=b]{ \FrameTitle{Zapf} \StartFrame[width=.75\textwidth] \input zapf \StopFrame } \stopbuffer \startbuffer[third] \setlayer[bglayer][x=.70\textwidth,y=.7\textheight,location=b]{ \FrameTitle{Tufte} \StartFrame[width=.75\textwidth] \input tufte \StopFrame } \stopbuffer \definesymbol[empty][] \definesymbol[one][{\getbuffer[first]}] \definesymbol[two][{\getbuffer[first,second]}] \definesymbol[three][{\getbuffer[first,second,third]}] \Topic{Stacks \& Layers} {\setupbodyfont[12pt] \definefieldstack[sequence] [one,two,three] [frame=off, offset=none, clickin=JS(Walk_Field{sequence})] {\fieldstack[sequence]} \goto{next}[JS(Walk_Field{sequence})] } \stoptext
Hi Renaud, Renaud AUBIN wrote:
Hi all,
I would use fieldstack with \getbuffer and overlays... Why the following code doesn't work ? Is there another way to do that ?
\setlayer is breaking the fields here, so that they become normal, inactive content (dunno why). If you remove it, the fields appear... but the positioning is now the problem. For testing I defined the symbols only to be equal to one buffer at a time (not a combination of them). Without this restriction you get really funny positions for them. HTH, Peter
TIA
Renaud
%%%%%%% stack.tex
\setupcolors[state=start] \usemodule[pre-original]
\defineoverlay[FunnyFrame][\useMPgraphic{FunnyFrame}] \defineframedtext[FunnyText][frame=off,background=FunnyFrame] \def\StartFrame{\startFunnyText} \def\StopFrame {\stopFunnyText } \def\FrameTitle#1% {\setMPtext{FunnyFrame}{\hbox spread 1em{\hss\strut#1\hss}}} \setMPtext{FunnyFrame}{} % initialize the text variable \startuseMPgraphic{FunnyFrame} picture p ; numeric o ; path a, b ; pair c ; p := textext.rt(\MPstring{FunnyFrame}) ; a := unitsquare xyscaled(OverlayWidth,OverlayHeight) ; o := BodyFontSize ; p := p shifted (2o,OverlayHeight-ypart center p) ; drawoptions (withpen pencircle scaled 1pt withcolor .625red) ; b := a randomized (o/2) ; fill b withcolor .85white ; draw b ; c := center p ; c := b intersectionpoint (c shifted (0,-o)--c shifted(0,o)) ; p := p shifted (c-center p) ; b := (boundingbox p) randomized (o/8) ; fill b withcolor .85white ; draw b ; draw p withcolor black; setbounds currentpicture to a ; \stopuseMPgraphic
\definelayer[bglayer][position=yes] \setupbackgrounds[text][background=bglayer] \setuplayer[bglayer][position=no,corner=bottom,height=\paperheight]
\starttext
\startbuffer[first] \setlayer[bglayer][x=.55\textwidth,y=.9\textheight,location=b]{ \FrameTitle{Knuth} \StartFrame[width=.75\textwidth] \input knuth \StopFrame } \stopbuffer
\startbuffer[second] \setlayer[bglayer][x=.625\textwidth,y=.8\textheight,location=b]{ \FrameTitle{Zapf} \StartFrame[width=.75\textwidth] \input zapf \StopFrame } \stopbuffer
\startbuffer[third] \setlayer[bglayer][x=.70\textwidth,y=.7\textheight,location=b]{ \FrameTitle{Tufte} \StartFrame[width=.75\textwidth] \input tufte \StopFrame } \stopbuffer
\definesymbol[empty][] \definesymbol[one][{\getbuffer[first]}] \definesymbol[two][{\getbuffer[first,second]}] \definesymbol[three][{\getbuffer[first,second,third]}]
\Topic{Stacks \& Layers}
{\setupbodyfont[12pt]
\definefieldstack[sequence] [one,two,three] [frame=off, offset=none, clickin=JS(Walk_Field{sequence})]
{\fieldstack[sequence]}
\goto{next}[JS(Walk_Field{sequence})] }
\stoptext
------------------------------------------------------------------------
_______________________________________________ ntg-context mailing list ntg-context@ntg.nl http://www.ntg.nl/mailman/listinfo/ntg-context
Hi all, After several trial-error experiments, I obtained what I want with the attached code. I use only one background for the frames within definesymbol because the use of several background "failed" (only the last one is eventually displayed). Now, I would like to know if it is possible to obtain a deterministic random-like shapes, i.e. to get always the same shape for Overlay1... Renaud PS: Thanks to Peter, Andrea and Hans for the thread absolute positioning of figures ;) \setupcolors[state=start] \usemodule[pre-original] \defineoverlay[FunnyFrame][\useMPgraphic{FunnyFrame}] \defineframedtext[FunnyText][frame=off,background=FunnyFrame] \def\StartFrame{\startFunnyText} \def\StopFrame {\stopFunnyText } \def\FrameTitle#1% {\setMPtext{FunnyFrame}{\hbox spread 1em{\hss\strut#1\hss}}} \setMPtext{FunnyFrame}{\hbox spread 1em{\hss\strut{TEST}\hss}} % initialize the text variable \startuseMPgraphic{FunnyFrame} picture p ; numeric o ; path a, b ; pair c ; p := textext.rt(\MPstring{FunnyFrame}) ; a := unitsquare xyscaled(OverlayWidth,OverlayHeight) ; o := BodyFontSize ; p := p shifted (2o,OverlayHeight-ypart center p) ; drawoptions (withpen pencircle scaled 1pt withcolor .625red) ; b := a randomized (o/2) ; fill b withcolor .85white ; draw b ; c := center p ; c := b intersectionpoint (c shifted (0,-o)--c shifted(0,o)) ; p := p shifted (c-center p) ; b := (boundingbox p) randomized (o/8) ; fill b withcolor .85white ; draw b ; draw p withcolor black; setbounds currentpicture to a ; \stopuseMPgraphic \starttext \Topic{Stacks \& Layers} \startbuffer[buf1] \FrameTitle{Overlay1} \StartFrame[width=.75\textwidth] This is the first funny frame ! \StopFrame \stopbuffer \startbuffer[buf2] \FrameTitle{Overlay2} \StartFrame[width=.75\textwidth] This is the second funny frame ! \StopFrame \stopbuffer \startbuffer[buf3] \FrameTitle{Overlay3} \StartFrame[width=.75\textwidth] This is the third funny frame ! \StopFrame \stopbuffer \definelayer[layer1][] \definelayer[layer2][] \definelayer[layer3][] \setlayer[layer1][x=.05\textwidth,y=.05\textheight,location=br]{\getbuffer[buf1]} \setlayer[layer2][x=.05\textwidth,y=.05\textheight,location=br]{\getbuffer[buf1]} \setlayer[layer2][x=.1\textwidth,y=.1\textheight,location=br]{\getbuffer[buf2]} \setlayer[layer3][x=.05\textwidth,y=.05\textheight,location=br]{\getbuffer[buf1]} \setlayer[layer3][x=.1\textwidth,y=.1\textheight,location=br]{\getbuffer[buf2]} \setlayer[layer3][x=.15\textwidth,y=.15\textheight,location=br]{\getbuffer[buf3]} \defineoverlay[overlay1][{\placelayer[layer1]}] \defineoverlay[overlay2][{\placelayer[layer2]}] \defineoverlay[overlay3][{\placelayer[layer3]}] \definesymbol[one][{\framed[width=\textwidth,height=.3\textheight,background=overlay1,frame=off]{}}] \definesymbol[two][{\framed[width=\textwidth,height=.3\textheight,background=overlay2, align=right,frame=off]{}}] \definesymbol[three][{\framed[width=\textwidth,height=.3\textheight,background=overlay3, align=right,frame=off]{}}] \definefieldstack[sequence][one,two,three][height=fit,width=fit,frame=off,offset=overlay,clickin=JS(Walk_Field{sequence})] {{\fieldstack[sequence]}} \goto{next}[JS(Walk_Field{sequence})] \stoptext
Hi Renaud, I tried your example code and it is really fun. But you should exchange the buffers with setups to minimize runtime. On my machine it's 4x faster this way. I'll better not imagine, how often you have compiled your example code, before it reached this nice and clean state ;) Renaud AUBIN wrote:
Hi all,
After several trial-error experiments, I obtained what I want with the attached code. I use only one background for the frames within definesymbol because the use of several background "failed" (only the last one is eventually displayed). Now, I would like to know if it is possible to obtain a deterministic random-like shapes, i.e. to get always the same shape for Overlay1...
What I can think of is to initialize the random seed value of MP (name?) with the same value, every time before you fill a new layer. Another way would be to add the 'random' parameters to your FrameTitle macro. But I don't have much experience with random stuff, so there maybe better ways. Greetings, Peter
Renaud
PS: Thanks to Peter, Andrea and Hans for the thread absolute positioning of figures ;)
\setupcolors[state=start] \usemodule[pre-original]
\defineoverlay[FunnyFrame][\useMPgraphic{FunnyFrame}] \defineframedtext[FunnyText][frame=off,background=FunnyFrame] \def\StartFrame{\startFunnyText} \def\StopFrame {\stopFunnyText } \def\FrameTitle#1% {\setMPtext{FunnyFrame}{\hbox spread 1em{\hss\strut#1\hss}}} \setMPtext{FunnyFrame}{\hbox spread 1em{\hss\strut{TEST}\hss}} % initialize the text variable \startuseMPgraphic{FunnyFrame} picture p ; numeric o ; path a, b ; pair c ; p := textext.rt(\MPstring{FunnyFrame}) ; a := unitsquare xyscaled(OverlayWidth,OverlayHeight) ; o := BodyFontSize ; p := p shifted (2o,OverlayHeight-ypart center p) ; drawoptions (withpen pencircle scaled 1pt withcolor .625red) ; b := a randomized (o/2) ; fill b withcolor .85white ; draw b ; c := center p ; c := b intersectionpoint (c shifted (0,-o)--c shifted(0,o)) ; p := p shifted (c-center p) ; b := (boundingbox p) randomized (o/8) ; fill b withcolor .85white ; draw b ; draw p withcolor black; setbounds currentpicture to a ; \stopuseMPgraphic
\starttext
\Topic{Stacks \& Layers}
\startbuffer[buf1] \FrameTitle{Overlay1} \StartFrame[width=.75\textwidth] This is the first funny frame ! \StopFrame \stopbuffer
\startbuffer[buf2] \FrameTitle{Overlay2} \StartFrame[width=.75\textwidth] This is the second funny frame ! \StopFrame \stopbuffer
\startbuffer[buf3] \FrameTitle{Overlay3} \StartFrame[width=.75\textwidth] This is the third funny frame ! \StopFrame \stopbuffer
\definelayer[layer1][] \definelayer[layer2][] \definelayer[layer3][]
\setlayer[layer1][x=.05\textwidth,y=.05\textheight,location=br]{\getbuffer[buf1]}
\setlayer[layer2][x=.05\textwidth,y=.05\textheight,location=br]{\getbuffer[buf1]} \setlayer[layer2][x=.1\textwidth,y=.1\textheight,location=br]{\getbuffer[buf2]}
\setlayer[layer3][x=.05\textwidth,y=.05\textheight,location=br]{\getbuffer[buf1]} \setlayer[layer3][x=.1\textwidth,y=.1\textheight,location=br]{\getbuffer[buf2]} \setlayer[layer3][x=.15\textwidth,y=.15\textheight,location=br]{\getbuffer[buf3]}
\defineoverlay[overlay1][{\placelayer[layer1]}] \defineoverlay[overlay2][{\placelayer[layer2]}] \defineoverlay[overlay3][{\placelayer[layer3]}]
\definesymbol[one][{\framed[width=\textwidth,height=.3\textheight,background=overlay1,frame=off]{}}] \definesymbol[two][{\framed[width=\textwidth,height=.3\textheight,background=overlay2, align=right,frame=off]{}}] \definesymbol[three][{\framed[width=\textwidth,height=.3\textheight,background=overlay3, align=right,frame=off]{}}]
\definefieldstack[sequence][one,two,three][height=fit,width=fit,frame=off,offset=overlay,clickin=JS(Walk_Field{sequence})]
{{\fieldstack[sequence]}} \goto{next}[JS(Walk_Field{sequence})]
\stoptext
_______________________________________________ ntg-context mailing list ntg-context@ntg.nl http://www.ntg.nl/mailman/listinfo/ntg-context
Hi Peter, all,
What I can think of is to initialize the random seed value of MP (name?) with the same value, every time before you fill a new layer. Another way would be to add the 'random' parameters to your FrameTitle macro. But I don't have much experience with random stuff, so there maybe better ways.
I use now \startsetups[buf1] \startMPinclusions randomseed:=1; \stopMPinclusions \FrameTitle{Overlay1} \StartFrame[width=.75\textwidth] This is the first funny frame ! \StopFrame \stopsetups \startsetups[buf2] \startMPinclusions randomseed:=2; \stopMPinclusions \FrameTitle{Overlay2} \StartFrame[width=.75\textwidth] This is the second funny frame ! \StopFrame \stopsetups \startsetups[buf3] \startMPinclusions randomseed:=3; \stopMPinclusions \FrameTitle{Overlay3} \StartFrame[width=.75\textwidth] This is the third funny frame ! \StopFrame \stopsetups and \setups{...}
Renaud AUBIN wrote:
Hi all,
After several trial-error experiments, I obtained what I want with the attached code. I use only one background for the frames within definesymbol because the use of several background "failed" (only the last one is eventually displayed). Now, I would like to know if it is possible to obtain a deterministic random-like shapes, i.e. to get always the same shape for Overlay1...
Renaud
PS: Thanks to Peter, Andrea and Hans for the thread absolute positioning of figures ;)
.... nice example .... if you're in exploration mode : take a look at s-pre-61/62 you can do similar tricks with pdf-layers (layout components in context) (try \showlayoutcomponents in a document and open the acrobat layer tab) i first used such layers in the dante2005 aniv presentation (times stepping, stacking page building) the advantage is that one is not using annotations, which have some limitations (like no embedded hyperlinks) Hans ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | fax: 038 477 53 74 | www.pragma-ade.com | www.pragma-pod.nl -----------------------------------------------------------------
participants (3)
-
Hans Hagen
-
Peter Rolf
-
Renaud AUBIN