Hello, How can I place an element as background at a previously defined position? Here a test-file to show what I'm looking for: \definelayer[graphics][position=yes] \setupbackgrounds[page][background=graphics] \starttext Here is some text. I would like to appear a graphics exactly behind \hpos{XXX}{HERE}. How can I do this, without measuring by hand the x- and y-offsets, and perhaps also without using metapost? Such a command would be fine: \type{\placeatpos[XXX]{my background figure}}, or \type{\setlayer[graphics][location=XXX]{...}}. \setlayer[graphics][dx=128mm, dy=-27mm]{\externalfigure[hacker.jpg][width=1cm]} \stoptext TIA for any help! Cheers, Peter -- Contact information: http://pmrb.free.fr/contact/
Am 06.02.10 23:17, schrieb Peter Münster:
Hello,
How can I place an element as background at a previously defined position?
Here a test-file to show what I'm looking for:
\definelayer[graphics][position=yes] \setupbackgrounds[page][background=graphics] \starttext Here is some text. I would like to appear a graphics exactly behind \hpos{XXX}{HERE}. How can I do this, without measuring by hand the x- and y-offsets, and perhaps also without using metapost?
untested: \newcounter\BackgroundPictures \definelayer[BackgroundPicture][width=\paperwidth,height=\paperheight] \def\FixedPicture {\dodoubleempty\doFixedPicture} \def\doFixedPicture[#1][#2]% {\doglobal\increment\BackgroundPictures \xypos{fixedpicture:\BackgroundPictures}% \doifnotmode{first} {\setlayer [BackgroundPicture] [x=\MPx{fixedpicture:\BackgroundPictures}, y=\MPy{fixedpicture:\BackgroundPictures}] {\externalfigure[#1][#2]}}} \setupbackgrounds[page][background=BackgroundPicture] \starttext ... \FixedPicture[...] ... \stoptext Wolfgang
On Sun, Feb 07 2010, Wolfgang Schuster wrote:
\newcounter\BackgroundPictures
\definelayer[BackgroundPicture][width=\paperwidth,height=\paperheight]
\def\FixedPicture {\dodoubleempty\doFixedPicture}
\def\doFixedPicture[#1][#2]% {\doglobal\increment\BackgroundPictures \xypos{fixedpicture:\BackgroundPictures}% \doifnotmode{first} {\setlayer [BackgroundPicture] [x=\MPx{fixedpicture:\BackgroundPictures}, y=\MPy{fixedpicture:\BackgroundPictures}] {\externalfigure[#1][#2]}}}
\setupbackgrounds[page][background=BackgroundPicture]
\starttext
... \FixedPicture[...] ...
\stoptext
Hello Wolfgang, No, it does not work. The main idea, to position the layer with x=\MPx{} and y=\MPy{} seems to be broken. Smaller test-file: \definelayer[graphics][position=yes] \setupbackgrounds[page][background=graphics] \starttext I would like to appear a graphics exactly 2cm left from he\xypos{XXX}re. \setlayer[graphics][x=\MPx{XXX}, y=\MPy{XXX}, dx=-2cm]{% \externalfigure[hacker.jpg][width=1cm]} \stoptext Any other ideas? Thanks, Peter -- Contact information: http://pmrb.free.fr/contact/
Am 07.02.10 13:22, schrieb Peter Münster:
The main idea, to position the layer with x=\MPx{} and y=\MPy{} seems to be broken.
Smaller test-file:
\definelayer[graphics][position=yes] \setupbackgrounds[page][background=graphics] \starttext I would like to appear a graphics exactly 2cm left from he\xypos{XXX}re.
\setlayer[graphics][x=\MPx{XXX}, y=\MPy{XXX}, dx=-2cm]{% \externalfigure[hacker.jpg][width=1cm]} \stoptext
Any other ideas?
Remove the 'position=yes' setup and correct the coordinates, layers use the top left corner as origin but positions are measures from the left bottom corner. \definelayer[graphics] \setupbackgrounds[page][background=graphics] \starttext I would like to appear a graphics exactly 2cm left from he\xypos{XXX}re. \setlayer [graphics] [x=\the\dimexpr\MPx{XXX}-2cm\relax, y=\the\dimexpr\paperheight-\MPy{XXX}-\strutht\relax] {\externalfigure[hacker.jpg][width=1cm]} \stoptext Wolfgang
On Sun, Feb 07 2010, Wolfgang Schuster wrote:
Remove the 'position=yes' setup and correct the coordinates, layers use the top left corner as origin but positions are measures from the left bottom corner.
Ah, now I see, why the graphics was at the bottom before. Thank you very much! Here an example to show how I use it: \usemodule[pre-stepwise] \setupinteraction[state=start] \definelayer[myBG] \setupbackgrounds[page][background=myBG] \def\PlaceAtPos{\dosingleempty\doPlaceAtPos} \def\doPlaceAtPos[#1]#2#3{% \getparameters[PAA][dx=0pt, dy=0pt, #1]% \setbox\scratchbox\hbox{#3}% \setlayer[myBG][% x=\the\dimexpr\MPx{#2} - 0.5\wd\scratchbox\relax, y=\the\dimexpr\paperheight-\MPy{#2}-\ht\scratchbox\relax, dx=\PAAdx, dy=\PAAdy]{#3}} \starttext Place something exactly 2cm left from he\xypos{XXX}re. Place something exactly 1 line below he\xypos{YYY}re. Place something exactly he\xypos{ZZZ}re. \StartSteps \PlaceAtPos[dx=-2cm]{XXX}{\red something} \FlushStep \PlaceAtPos[dy=\lineheight]{YYY}{\green something} \FlushStep \PlaceAtPos{ZZZ}{\blue something} \FlushStep \StopSteps \stoptext Cheers, Peter -- Contact information: http://pmrb.free.fr/contact/
Am 07.02.10 15:26, schrieb Peter Münster:
\def\doPlaceAtPos[#1]#2#3{% \getparameters[PAA][dx=0pt, dy=0pt, #1]% \setbox\scratchbox\hbox{#3}% \setlayer[myBG][% x=\the\dimexpr\MPx{#2} - 0.5\wd\scratchbox\relax, y=\the\dimexpr\paperheight-\MPy{#2}-\ht\scratchbox\relax, dx=\PAAdx, dy=\PAAdy]{#3}}
\def\doPlaceAtPos[#1]#2% {\dowithnextbox {\setlayer [myBG] [x=\the\dimexpr\MPx{#2}-\nextboxwd/2\relax, y=\the\dimexpr\paperheight-\MPy{#2}-\nextboxht\relax, #1] {\flushnextbox}} \normalhbox} Wolfgang
On Sun, Feb 07 2010, Wolfgang Schuster wrote:
\def\doPlaceAtPos[#1]#2#3{% \getparameters[PAA][dx=0pt, dy=0pt, #1]% \setbox\scratchbox\hbox{#3}% \setlayer[myBG][% x=\the\dimexpr\MPx{#2} - 0.5\wd\scratchbox\relax, y=\the\dimexpr\paperheight-\MPy{#2}-\ht\scratchbox\relax, dx=\PAAdx, dy=\PAAdy]{#3}}
\def\doPlaceAtPos[#1]#2% {\dowithnextbox {\setlayer [myBG] [x=\the\dimexpr\MPx{#2}-\nextboxwd/2\relax, y=\the\dimexpr\paperheight-\MPy{#2}-\nextboxht\relax, #1] {\flushnextbox}} \normalhbox}
Thank you for this \dowithnextbox command! (I keep \getparameters... because I want to use it for other parameters outside of \setlayer) Cheers, Peter -- Contact information: http://pmrb.free.fr/contact/
participants (2)
-
Peter Münster
-
Wolfgang Schuster