Add lamp symbols (normal and illuminating) to Circ.asy.
authorW. Trevor King <wking@tremily.us>
Mon, 30 Apr 2012 17:51:16 +0000 (13:51 -0400)
committerW. Trevor King <wking@tremily.us>
Mon, 30 Apr 2012 17:51:16 +0000 (13:51 -0400)
asymptote/Circ-test.asy
asymptote/Circ.asy

index e8030e083d61c429f037555bd1d6ddfa011058d1..44bfc7cdca00d5853f063eef8e4f3860053f6e92 100644 (file)
@@ -65,6 +65,11 @@ TwoTerminal Sdc = source((0,v), 0, DC, "DC", "5 V");
 TwoTerminal Sac = source((u,v), 0, AC, "AC", "5 V$_{pp}$");
 TwoTerminal Si = source((2u,v), 0, I, "I", "5 A");
 TwoTerminal Sv = source((3u,v), 0, V, "V", "5 V");
+v -= u;
+
+write("lamp");
+TwoTerminal Ln = lamp((0,v), 0, normal, "indicator", "5\ohm");
+TwoTerminal Li = lamp((u,v), 0, illuminating, "illuminator", "5\ohm");
 v -= 1.5u;
 
 write("positioning");
index a10cffb1d7e160422b0e58dcb907864bbb3eafa2..fac33372de95dd1edc4cb18a026f39a47e76ae6a 100644 (file)
@@ -867,35 +867,40 @@ vardef impedance@#(expr z,ang,name,val)=
        putlabel(Z@#.l,Z@#.r,.2implth,.2implth,ang,name,val);
 enddef;
 
-vardef lamp@#(expr z,ang,name,val)=
-       save ampl, p, q, r, s;
-       pair La@#.l,La@#.r; % pines %
-       La@#.l=z; La@#.r=(z+(2ssize,0)) rotatedaround(z,ang);
-       
-       picture ampl; ampl=nullpicture;
-       
-       addto ampl doublepath z--(z+(.5ssize,0));
-       addto ampl doublepath fullcircle scaled ssize shifted (z+(ssize,0));
-       addto ampl doublepath (z+(1.5ssize,0))--(z+(2ssize,0));
-       
-       pair p, q, r, s;
-       p=(-ssize*dir 45 shifted (z+(ssize,0))--(z+(ssize,0))) intersectionpoint
-       (fullcircle scaled ssize shifted (z+(ssize,0)));
-       q=(ssize*dir 45 shifted (z+(ssize,0))--(z+(ssize,0))) intersectionpoint
-       (fullcircle scaled ssize shifted (z+(ssize,0)));
-       r=(-ssize*dir (-45) shifted (z+(ssize,0))--(z+(ssize,0))) intersectionpoint
-       (fullcircle scaled ssize shifted (z+(ssize,0)));
-       s=(ssize*dir (-45) shifted (z+(ssize,0))--(z+(ssize,0))) intersectionpoint
-       (fullcircle scaled ssize shifted (z+(ssize,0)));
-       
-       addto ampl doublepath p--q;
-       addto ampl doublepath r--s;
-       
-       draw ampl rotatedaround(z,ang) withpen line;
-       
-       putlabel(La@#.l,La@#.r,.5ssize,.5ssize,ang,name,val);
-enddef;
+*/
+
+real lampsize = ssize;
+int illuminating = 1;
+
+TwoTerminal lamp(pair beg=(0,0), real ang=0, int type=normal,
+                 string name="", string val="", bool draw=true)
+{
+  path pLine[]={}, pMisc[]={};
+  real len, lchar, lcharv, r = 0.5*lampsize;
+  pair c = (2r,0);
+  TwoTerminal term;
 
+  len = 2*lampsize;
+  lchar = lcharv = r;
+  c = (lampsize, 0);
+  pLine.push((0,0)--(r,0));
+  pLine.push(shift(c)*scale(r)*(E..N..W..S..E));
+  pLine.push((1.5*lampsize,0)--(2*lampsize,0));
+  if (type==normal) {
+    pLine.push((c - r*dir(45)) -- (c + r*dir(45)));
+    pLine.push((c - r*dir(-45)) -- (c + r*dir(-45)));
+  } else if (type==illuminating) {
+    pLine.push((c - (r,0)) -- (c - (r/2,0)));
+    pLine.push((c + (r/2,0)) -- (c + (r,0)));    
+    pLine.push(shift(c)*scale(r/2)*(E..N..W));
+  }
+  term = TwoTerminal(beg, len, ang, lchar, lcharv, name, val, pLine, pMisc);
+  if (draw == true)
+    term.draw();
+  return term;
+}
+
+/*
 
 //%%<--- Mesh current (corriente de malla) --->%%%