setObjectDefaultOption("Box")("framewidth")(.75mm);
setObjectDefaultOption("Circle")("framewidth")(.75mm);
setObjectDefaultOption("Circle")("circmargin")(3mm);
+setObjectDefaultOption("Mux")("framewidth")(.75mm);
%ahlength := 1.5mm;
ahangle := 60;
setObjectDefaultOption("Reg")("reflect")(false);
setObjectDefaultOption("Reg")("labels")(false);
+% Define a Multiplexer.
+vardef newMux@# text options=
+ ExecuteOptions(@#)(options);
+ assignObj(@#,"Mux");
+ StandardInterface;
+ % Add ports
+ ObjPoint inpa, inpb, out;
+
+ ObjCode MinimumStandardEquations,
+ % Make it a parallel trapezium
+ "xpart(@#ne - @#nw) = xpart(@#se - @#sw)",
+ "ypart(@#ne - @#nw) = -1 * ypart(@#se - @#sw)",
+ % Use a 22.5 degree angle for the sides
+ "ypart(@#nw) - ypart(@#ne) = xpart(@#ne-@#nw) / 2",
+ % With a specific width and height
+ "@#e-@#w = (" & decimal OptionValue@#("width") & ", 0mm)",
+ "@#n-@#s = (0mm, " & decimal OptionValue@#("height") & ")",
+ % And space the input ports evenly
+ "@#inpa = midpoint(@#nw, @#w)",
+ "@#inpb = midpoint(@#w, @#sw)",
+ "@#out = @#e";
+
+ StandardTies;
+enddef;
+
+% Draw a multiplexer
+def drawMux(suffix mux)=
+ draw mux.n -- mux.s;
+ % Use our bounding path to draw
+ drawFramedOrFilledObject_(mux);
+enddef;
+
+% Bounding path for a multiplexer
+def BpathMux(suffix n)=StandardBpath(n) enddef;
+
+% Define options
+define_local_numeric_option("width");
+define_local_numeric_option("height");
+setObjectDefaultOption("Mux")("width")(5mm);
+setObjectDefaultOption("Mux")("height")(20mm);
+setObjectDefaultOption("Mux")("framed")(true);
+% Overidden above
+%setObjectDefaultOption("Mux")("framewidth")(.5bp);
+setObjectDefaultOption("Mux")("framecolor")(black);
+setObjectDefaultOption("Mux")("framestyle")("");
+setObjectDefaultOption("Mux")("shadow")(false);
+setObjectDefaultOption("Mux")("shadowcolor")(black);
+setObjectDefaultOption("Mux")("filled")(false);
+setObjectDefaultOption("Mux")("fillcolor")(black);
+
+
def midpoint(expr a, b) = ((a + b) / 2) enddef;
\stopMPinclusions