From da3ca531d2693bde6e25b2fcb97d3378272cac6f Mon Sep 17 00:00:00 2001 From: "W. Trevor King" Date: Tue, 4 Aug 2009 15:20:18 -0400 Subject: [PATCH] Added more label positioning arguments to Distance.draw(). --- asymptote/Mechanics.asy | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/asymptote/Mechanics.asy b/asymptote/Mechanics.asy index 907eac7..3eeb86a 100644 --- a/asymptote/Mechanics.asy +++ b/asymptote/Mechanics.asy @@ -132,12 +132,16 @@ struct Distance { this.L = L; } - void draw(picture pic=currentpicture, bool rotateLabel=true) { + void draw(picture pic=currentpicture, bool rotateLabel=true, + real labelangle=90, real labeloffset=-1) { picture picF; - picture picL; - label(picL, L); - pair pLabelSize = 1.2 * (max(picL)-min(picL)); pair pDiff = pTo - pFrom; + if (labeloffset == -1) { + picture picL; + label(picL, L); + pair pLabelSize = 1.2 * (max(picL)-min(picL)); + labeloffset = pLabelSize.y/2; + } path p = (0,0)--pDiff; pair label_rotate=pDiff; if (rotateLabel == false) @@ -146,7 +150,7 @@ struct Distance { label(pic = picF, L = rotate(degrees(label_rotate)) * L, position = pDiff/2 - + unit(rotate(90)*pDiff) * pLabelSize.y / 2); + + unit(rotate(labelangle)*pDiff) * labeloffset); //label(pic=picF, L = rotate(degrees(label_rotate)) format("%g", pDiff/scale), position = TODO); add(pic, picF, pFrom+offset*unit(rotate(-90)*pDiff)); } -- 2.26.2