Menu

#47 Draw a path in user coordinates plus a shift in postscript coordinates

None
open
nobody
None
5
2014-04-28
2014-04-28
No

Sometimes, to produce an image that scales well, it's useful to be able to specify a path in user coordinates, but add a shift in postscript coordinates. ("This brace should be exactly 5mm to the left of the line segment it describes.") One possible starting place is the code in this FAQ. I do have my own routine for this, but I don't fully understand how it works, so use it with caution:

void drawshifted(path g, pair trueshift, picture pic =
    currentpicture, Label label="", pen pen=currentpen,
    arrowbar arrow=None, arrowbar bar=None, margin
    margin=NoMargin, marker marker=nomarker)
{
  picture opic;
  draw(opic, L=label, g, p=pen, arrow=arrow, bar=bar,
      margin=margin, marker=marker);
  pic.add(new void(frame f, transform t) {
     add(f,opic.fit(shift(trueshift)*t));
    });
  pic.addBox(min(opic), max(opic), trueshift, trueshift);
}

Discussion


Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.