Add pChargePen and other charge-fill pens to ElectroMag.asy.
authorW. Trevor King <wking@drexel.edu>
Thu, 12 Apr 2012 00:37:14 +0000 (20:37 -0400)
committerW. Trevor King <wking@drexel.edu>
Thu, 12 Apr 2012 00:37:14 +0000 (20:37 -0400)
asymptote/ElectroMag.asy

index 2a7818220381d84b1be88a6e2d58afe65b9fafd8..52d6dd1f40163630c67feab938da8e8825390daa 100644 (file)
@@ -23,13 +23,17 @@ import Mechanics;
 
 // ---------------------- Charges -------------------------
 
+pen pChargePen = red;
+pen nChargePen = blue;
+pen neutralChargePen = grey;
+
 // charged particle
 struct Charge {
   LabeledCircle lc;
   real q;
   
   void operator init(pair center=(0,0), real q=1, real radius=2mm,
-                     pen outline=currentpen, pen fill=red, Label L="") {
+                     pen outline=currentpen, pen fill=pChargePen, Label L="") {
     this.lc.operator init(center=center, radius=radius, outline=outline,
                           fill=fill, L=L);
     this.q = q;
@@ -44,24 +48,24 @@ struct Charge {
 Charge pCharge(pair center=(0,0), real q=1, real radius=2mm,
                pen outline=currentpen, Label L="")
 {
-  return Charge(center=center, q=q, radius=radius, outline=outline, fill=red,
-                L=L);
+  return Charge(center=center, q=q, radius=radius, outline=outline,
+                fill=pChargePen, L=L);
 }
 
 // negative charge
 Charge nCharge(pair center=(0,0), real q=-1, real radius=2mm,
                pen outline=currentpen, Label L="")
 {
-  return Charge(center=center, q=q, radius=radius, outline=outline, fill=blue,
-                L=L);
+  return Charge(center=center, q=q, radius=radius, outline=outline,
+                fill=nChargePen, L=L);
 }
 
 // neutral charge
 Charge neutralCharge(pair center=(0,0), real radius=2mm,
                      pen outline=currentpen, Label L="")
 {
-  return Charge(center=center, q=0, radius=radius, outline=outline, fill=grey,
-                L=L);
+  return Charge(center=center, q=0, radius=radius, outline=outline,
+                fill=neutralChargePen, L=L);
 }
 
 // auto-signed charge