return term;
}
+//--- Circle-based symbols (for internal use) --
+
+real circle_size=6mm;
+
+TwoTerminal _two_terminal_circle(pair beg=(0,0), real ang=0, string name="",
+ string val="")
+{
+ path pLine[]={}, pMisc[]={};
+ real len, lchar, lcharv, r = circle_size/2;
+ pair c = (2r,0);
+ TwoTerminal term;
+
+ len = 2*circle_size;
+ lchar = lcharv = r;
+ c = (circle_size, 0);
+ pLine.push((0,0)--(r,0));
+ pLine.push(shift(c)*scale(r)*(E..N..W..S..E));
+ pLine.push((3r,0)--(4r,0));
+ term = TwoTerminal(beg, len, ang, lchar, lcharv, name, val, pLine, pMisc);
+ return term;
+}
+
//--- Sources (fuentes de alimentaci'on) ---
-real ssize=6mm;
int AC=0,DC=1,I=2,V=3;
TwoTerminal source(pair beg=(0,0), real ang=0, int type=AC, string name="",
- string val="", bool draw=true)
+ string val="", bool draw=true)
{
- path pLine[]={}, pMisc[]={};
- real len, lchar, lcharv;
TwoTerminal term;
-
if (type == AC || type == I || type == V) {
- len = 2ssize;
- lchar = 0.5ssize; lcharv = 0.5ssize;
- pLine.push((0,0)--(.5ssize,0));
- pLine.push(shift((ssize,0))*scale(ssize/2)*(E..N..W..S..E));
- pLine.push((1.5ssize,0)--(2ssize,0));
+ real s = circle_size;
+ term = _two_terminal_circle(beg=beg, ang=ang, name=name, val=val);
if (type == AC) {
- pLine.push((2ssize/3,0ssize){NE}..{E}((1/3+.5)*ssize,.2ssize)..{SE}(ssize,0)..{E}((2/3+.5)*ssize,-.2ssize)..{NE}(4ssize/3,0));
+ term.pLine.push((2s/3,0){NE}..{E}((1/3+.5)*s,.2s)..{SE}(s,0)..{E}((2/3+.5)*s,-.2s)..{NE}(4s/3,0));
} else if (type == I) {
- pLine.push((2ssize/3,0)--(4ssize/3,0));
- pLine.push(fullhead(pLine[3], 4ssize/15, 30));
+ term.pLine.push((2s/3,0)--(4s/3,0));
+ term.pLine.push(fullhead(term.pLine[3], 4s/15, 30));
} else if (type == V) {
- pLine.push((1.05ssize,0)--(1.45ssize,0));
- pLine.push((1.25ssize,-.2ssize)--(1.25ssize,.2ssize));
- pLine.push((.95ssize,0)--(.55ssize,0));
+ term.pLine.push((1.05s,0)--(1.45s,0));
+ term.pLine.push((1.25s,-.2s)--(1.25s,.2s));
+ term.pLine.push((.95s,0)--(.55s,0));
}
} else if (type == DC) {
- len = ssize;
- lchar = 0.6ssize; lcharv = .6ssize;
- pLine.push((0,0)--(0.4ssize,0));
- pLine.push((.6ssize,0)--(ssize,0));
- pLine.push((.4ssize,-.2ssize)--(.4ssize,.2ssize));
- pLine.push((.6ssize,-.6ssize)--(.6ssize,.6ssize));
+ path pLine[] = {};
+ real len, lchar, lcharv;
+ len = circle_size;
+ lchar = 0.6len; lcharv = .6len;
+ pLine.push((0,0)--(0.4len,0));
+ pLine.push((.6len,0)--(len,0));
+ pLine.push((.4len,-.2len)--(.4len,.2len));
+ pLine.push((.6len,-.6len)--(.6len,.6len));
+ term = TwoTerminal(beg, len, ang, lchar, lcharv, name, val, pLine);
}
- term = TwoTerminal(beg, len, ang, lchar, lcharv, name, val, pLine, pMisc);
if (draw == true)
term.draw();
return term;
*/
-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);
+ real r = 0.5*circle_size;
+ pair c;
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));
+ term = _two_terminal_circle(beg=beg, ang=ang, name=name, val=val);
+ pair c = (2r, 0);
if (type==normal) {
- pLine.push((c - r*dir(45)) -- (c + r*dir(45)));
- pLine.push((c - r*dir(-45)) -- (c + r*dir(-45)));
+ term.pLine.push((c - r*dir(45)) -- (c + r*dir(45)));
+ term.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.pLine.push((c - (r,0)) -- (c - (r/2,0)));
+ term.pLine.push((c + (r/2,0)) -- (c + (r,0)));
+ term.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;