From e2be7dee0ee0411ca3c4aa3c739ce23c3c5ebbd4 Mon Sep 17 00:00:00 2001 From: "W. Trevor King" Date: Wed, 11 Apr 2012 12:00:34 -0400 Subject: [PATCH] Don't break with Asymptote conventions. Use Label L instead of Label label. --- asymptote/ElectroMag.asy | 24 ++++++++++++------------ asymptote/Mechanics-test.asy | 10 +++++----- asymptote/Mechanics.asy | 30 +++++++++++++++--------------- 3 files changed, 32 insertions(+), 32 deletions(-) diff --git a/asymptote/ElectroMag.asy b/asymptote/ElectroMag.asy index 0e962aa..d37c738 100644 --- a/asymptote/ElectroMag.asy +++ b/asymptote/ElectroMag.asy @@ -29,9 +29,9 @@ struct Charge { real q; void operator init(pair center=(0,0), real q=1, real radius=2mm, - pen outline=currentpen, pen fill=red, Label label="") { + pen outline=currentpen, pen fill=red, Label L="") { this.lc.operator init(center=center, radius=radius, outline=outline, - fill=fill, label=label); + fill=fill, L=L); this.q = q; } @@ -42,39 +42,39 @@ struct Charge { // positive charge Charge pCharge(pair center=(0,0), real q=1, real radius=2mm, - pen outline=currentpen, Label label="") + pen outline=currentpen, Label L="") { return Charge(center=center, q=q, radius=radius, outline=outline, fill=red, - label=label); + L=L); } // negative charge Charge nCharge(pair center=(0,0), real q=-1, real radius=2mm, - pen outline=currentpen, Label label="") + pen outline=currentpen, Label L="") { return Charge(center=center, q=q, radius=radius, outline=outline, fill=blue, - label=label); + L=L); } // neutral charge Charge neutralCharge(pair center=(0,0), real radius=2mm, - pen outline=currentpen, Label label="") + pen outline=currentpen, Label L="") { return Charge(center=center, q=0, radius=radius, outline=outline, fill=grey, - label=label); + L=L); } // auto-signed charge Charge aCharge(pair center=(0,0), real q=1, real radius=2mm, - pen outline=currentpen, Label label="") + pen outline=currentpen, Label L="") { Charge c; if (q > 0) { - c = pCharge(center, q, radius, outline, label); + c = pCharge(center, q, radius, outline, L); } else if (q < 0) { - c = nCharge(center, q, radius, outline, label); + c = nCharge(center, q, radius, outline, L); } else { - c = neutralCharge(center, radius, outline, label); + c = neutralCharge(center, radius, outline, L); } return c; } diff --git a/asymptote/Mechanics-test.asy b/asymptote/Mechanics-test.asy index e6d5b3a..cf40947 100644 --- a/asymptote/Mechanics-test.asy +++ b/asymptote/Mechanics-test.asy @@ -26,14 +26,14 @@ lc.draw(); lc.label = "a"; lc.center = (-2u, 0.5u); lc.draw(); -lc.draw_label(label=Label("e", align=E)); +lc.draw_label(Label("e", align=E)); lc.center = (-2u, 0); lc.label.align = W; lc.draw(); -lc.draw_label(label="b"); -lc.draw_label(label=Label("c", align=E)); -lc.draw_label(label=rotate(90)*Label("e------I", align=S)); -lc.draw_label(label=rotate(45)*Label("e------I", align=S)); +lc.draw_label("b"); +lc.draw_label(Label("c", align=E)); +lc.draw_label(rotate(90)*Label("e------I", align=S)); +lc.draw_label(rotate(45)*Label("e------I", align=S)); lc.center = (-2u, -2u); lc.radius = u/2; lc.label.align = E; diff --git a/asymptote/Mechanics.asy b/asymptote/Mechanics.asy index 841414c..97e6889 100644 --- a/asymptote/Mechanics.asy +++ b/asymptote/Mechanics.asy @@ -29,32 +29,32 @@ struct LabeledCircle { Label label; void operator init(pair center=(0,0), real radius=2mm, - pen outline=currentpen, pen fill=grey, Label label="") { + pen outline=currentpen, pen fill=grey, Label L="") { this.center = center; this.radius = radius; this.outline = outline; this.fill = fill; - this.label = label; + this.label = L; } - void draw_label(picture pic=currentpicture, Label label=null) { + void draw_label(picture pic=currentpicture, Label L=null) { picture picL; align a; - if (label == null) { - label = this.label; + if (L == null) { + L = this.label; } - a = label.align; - if (label.align != NoAlign && label.align != Align) { - real m = labelmargin(label.p); + a = L.align; + if (L.align != NoAlign && L.align != Align) { + real m = labelmargin(L.p); real scale = (m + this.radius)/m; - if (label.align.is3D) { - label.align.dir3 *= scale; + if (L.align.is3D) { + L.align.dir3 *= scale; } else { - label.align.dir *= scale; + L.align.dir *= scale; } } - label(pic=pic, L=label, position=this.center); - label.align = a; + label(pic=pic, L=L, position=this.center); + L.align = a; } void draw(picture pic=currentpicture) { @@ -71,9 +71,9 @@ struct Mass { real m; void operator init(pair center=(0,0), real m=1, real radius=2mm, - pen outline=currentpen, pen fill=grey, Label label="") { + pen outline=currentpen, pen fill=grey, Label L="") { this.lc.operator init(center=center, radius=radius, outline=outline, - fill=fill, label=label); + fill=fill, L=L); this.m = m; } -- 2.26.2