What does the .fit() method of a picture do in the following Asymptote code?

picture pic1;
real size=50;

picture pic2;

picture pic3;

picture pic;


This is from the manual of Asymptote: http://asymptote.sourceforge.net/doc/Frames-and-pictures.html

The result is

enter image description here

Without the .fit() method the code fails with the error

fun.asy: 15.4: no matching function 'add(picture, picture, pair, pair)'

The function does not seem to be documented anywhere. There is however a cryptic comment on that same page dealing with fitting pictures to frames which says

A picture pic can be explicitly fit to a frame by calling

frame pic.fit(real xsize=pic.xsize, real ysize=pic.ysize, bool keepAspect=pic.keepAspect);

I am not sure I understand this properly. Is there a simple example which can explain the behaviour of this function?

  • 2
    Basically this method converts a picture to a frame. In a picture, there are two coordinate systems -- one for drawing, and one for pen nibs. So, for instance, if you multiply a picture by scale(2.0), the lines get longer but not thicker. Once you convert a picture to a frame, there is only one coordinate system; if you scale the frame size, it rescales both the length and the thickness of lines. (And if you rescale a frame by different x and y scales, your dots become ovals.) – Charles Staats Nov 19 '18 at 16:35
  • Ok thanks! Can you also explain how the add function is used in the example above? From the asymptote terminal, I found that the appropriate function type of the add function being used is <void add(picture dest=<default>, frame src, pair position, pair align, bool group=<default>, filltype filltype=<default>, bool above=<default>)> I am not sure what position and align mean. If I had not seen the output of the code above, I would have guessed that the lower left corner of the triangle would have been directly vertically over the center of the circle, but it isn't so in the output. – smilingbuddha Nov 19 '18 at 18:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.