Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I want to make a series of images with Metapost and Context. I want the height and width of the images to be fixed ( like a frame ) and center the picture drawn with Metapost inside that frame. So, is there a way to make the boundary values fixed with Metapost??

share|improve this question
add comment

1 Answer

up vote 8 down vote accepted

You can at least use the bbox command on the metapost -side of things, short for bounding box:

\def\myBoundingBox#1{\scale[width=3cm,height=1cm]{\useMPgraphic{#1}}}

\startMPdefinitions
  bboxmargin := 1cm; % note: the context-side scaling affects this, naturally
\stopMPdefinitions

\startuseMPgraphic{first}
  z0 = (0.5cm,1.5cm) ; z1 = (2.5cm,2.5cm) ;
  z2 = (6.5cm,0.5cm) ; z3 = (3.0cm,1.5cm) ;

  pickup pencircle xscaled 2mm yscaled 4mm rotated 30 ;
  draw z0..z1..z2..z3..z0..cycle withcolor lightgray ;

  draw bbox currentpicture withpen pencircle scaled 1pt;
\stopuseMPgraphic

\starttext

Nothing is impossible, the word itself says “I’m possible”!

---~Audrey Hepburn
\myBoundingBox{first}

\stoptext

The line-widths will then differ depending on how much down-/up-scaling needed to be done for the graphic. It would therefore make more sense to do the framing in ConTeXt -side of things, so at least the frame line-width would stay the same (and frame padding).

enter image description here

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.