MP newbie question
![](https://secure.gravatar.com/avatar/1f1420d2f042c8497d63406a4033a676.jpg?s=120&d=mm&r=g)
Hi, How do you make this work ? --- mpframed.tex --- %\def\myFrameAlternative{line} %\def\myFrameAlternative{dashes} \def\myFrameAlternative{dots} \startuniqueMPgraphic{name} path p ; p := unitsquare xscaled \overlaywidth yscaled \overlayheight ; show (\myFrameAlternative) ; if \myFrameAlternative = dashes : % if (\myFrameAlternative) = dashes : draw p dashed evenly scaled 2 ; % elseif (\myFrameAlternative) = dots : elseif \myFrameAlternative = dots : draw p dashed withdots scaled 2 ; else : draw p ; fi ; \stopuniqueMPgraphic \defineoverlay[myGraphic][\uniqueMPgraphic{name}] \starttext \framed[% offset=5mm, background=myGraphic, frame=off] {mp framed} \stoptext --- context.cmd mpframed -- Alan
![](https://secure.gravatar.com/avatar/c5ae4f9aa0d3a9bd5376e92b322c3e50.jpg?s=120&d=mm&r=g)
On Mon, 18 May 2009, Alan Stone wrote:
Hi, How do you make this work ?
--- mpframed.tex ---
%\def\myFrameAlternative{line} %\def\myFrameAlternative{dashes} \def\myFrameAlternative{dots}
I usually do (untested) \chardef\myFrameAlternative \myFrameAlternative \zerocount %(or \plusone or \plustwo) and then
\startuniqueMPgraphic{name}
path p ;
p := unitsquare xscaled \overlaywidth yscaled \overlayheight ; show (\myFrameAlternative) ;
\ifcase \myFramedAlternative draw p dashed evenly scaled 2 ; \or draw p dashed with dots scaled 2 ; \or draw p; \fi
if \myFrameAlternative = dashes : % if (\myFrameAlternative) = dashes : draw p dashed evenly scaled 2 ; % elseif (\myFrameAlternative) = dots : elseif \myFrameAlternative = dots : draw p dashed withdots scaled 2 ; else : draw p ; fi ; \stopuniqueMPgraphic
\defineoverlay[myGraphic][\uniqueMPgraphic{name}]
\starttext
\framed[% offset=5mm, background=myGraphic, frame=off] {mp framed}
\stoptext
Aditya
![](https://secure.gravatar.com/avatar/1f1420d2f042c8497d63406a4033a676.jpg?s=120&d=mm&r=g)
On Mon, May 18, 2009 at 8:45 PM, Alan Stone
Hi, How do you make this work ?
--- mpframed.tex ---
%\def\myFrameAlternative{line} %\def\myFrameAlternative{dashes} \def\myFrameAlternative{dots}
The MetaPost User Manual brought the answer... %\def\myFrameAlternative{"line"} %\def\myFrameAlternative{"dashes"} \def\myFrameAlternative{"dots"}
\startuniqueMPgraphic{name}
path p ;
p := unitsquare xscaled \overlaywidth yscaled \overlayheight ; show (\myFrameAlternative) ;
if \myFrameAlternative = dashes :
if \myFrameAlternative = "dashes" : Alan
% if (\myFrameAlternative) = dashes : draw p dashed evenly scaled 2 ; % elseif (\myFrameAlternative) = dots : elseif \myFrameAlternative = dots : draw p dashed withdots scaled 2 ; else : draw p ; fi ; \stopuniqueMPgraphic
\defineoverlay[myGraphic][\uniqueMPgraphic{name}]
\starttext
\framed[% offset=5mm, background=myGraphic, frame=off] {mp framed}
\stoptext
---
context.cmd mpframed
-- Alan
participants (2)
-
Aditya Mahajan
-
Alan Stone