Closed user202729 closed 2 weeks ago
This could explain some very weird results I got years ago when I was trying to imitate the tikz spy
library in asymptote. Either way, this at least sounds like a good reason to deprecate the function. (I doubt it would ever be deleted, but using it could case a warning to be printed out.)
We need a functionality like this since some functions have only been implemented for pictures (which are more general than frames).
But we could replace it with a version that behaves the same as currently if src
has no size
(or unitsize
) specification, which is really the intended use case elsewhere in the plain_*.asy files. Otherwise if src
has a size
(or unitsize
) specification, we could perhaps accept the backwards incompatibility (which likely has been rarely used; ignoring a specified size isn't an expected behaviour, as you point out):
// Fit the picture src and add it about the point position to picture dest.
void add(picture dest, picture src, pair position, bool group=true,
filltype filltype=NoFill, bool above=true)
{
add(dest,src.fit(),position,group,filltype,true);
// add(dest,src.fit(identity()),position,group,filltype,above);
}
If the main use case is in other plain_*.asy files... Should we consider making this function private?
This function is useful whenever the user wants to add a fixed-size object at a certain location. See for example this function in plain_picture.asy
:
void fill(pair origin, picture pic=currentpicture, path[] g, pen p=currentpen)
{
picture opic;
fill(opic,g,p);
add(pic,opic,origin);
}
... because it automatically interprets 1 user coordinate in
src
to be 1pt, which does not make much sense.There is already
add(picture dest, frame src, pair position)
variant. The user could explicitly setunitsize(1pt)
then callpicture.fit()
on it, which is not very difficult. Or even better, useframe
data type from the start.This is backwards incompatible, however.