forked from HEL/circuiteria
		
	fixed multiplexers with named ports + minor changes
This commit is contained in:
		| @@ -3,6 +3,8 @@ | ||||
|  | ||||
| /// Draws a block circuit diagram | ||||
| /// | ||||
| /// This function is also available as `circuiteria.circuit()` | ||||
| /// | ||||
| /// - body (none, array, element): A code block in which draw functions have been called | ||||
| /// - length (length, ratio): Optional base unit | ||||
| /// -> none | ||||
|   | ||||
| @@ -48,7 +48,6 @@ | ||||
|   stroke: black + 1pt, | ||||
|   id: "", | ||||
|   debug: ( | ||||
|     grid: false, | ||||
|     ports: false | ||||
|   ) | ||||
| ) = { | ||||
|   | ||||
| @@ -26,7 +26,6 @@ | ||||
|   stroke: black + 1pt, | ||||
|   id: "", | ||||
|   debug: ( | ||||
|     grid: false, | ||||
|     ports: false | ||||
|   ) | ||||
| ) = element.elmt( | ||||
|   | ||||
| @@ -32,7 +32,6 @@ | ||||
|   auto-ports: true, | ||||
|   ports-y: (), | ||||
|   debug: ( | ||||
|     grid: false, | ||||
|     ports: false | ||||
|   ) | ||||
| ) = draw.get-ctx(ctx => { | ||||
|   | ||||
| @@ -36,7 +36,6 @@ | ||||
|   stroke: black + 1pt, | ||||
|   id: "", | ||||
|   debug: ( | ||||
|     grid: false, | ||||
|     ports: false | ||||
|   ) | ||||
| ) = { | ||||
|   | ||||
| @@ -33,7 +33,6 @@ | ||||
|   stroke: black + 1pt, | ||||
|   id: "", | ||||
|   debug: ( | ||||
|     grid: false, | ||||
|     ports: false | ||||
|   ) | ||||
| ) = { | ||||
| @@ -45,6 +44,10 @@ | ||||
|       let bits = util.lpad(str(i, base: 2), nbits) | ||||
|       ports.push((id: "in" + str(i), name: bits)) | ||||
|     } | ||||
|   } else { | ||||
|     for (i, port) in entries.enumerate() { | ||||
|       ports.push((id: "in" + str(i), name: port)) | ||||
|     } | ||||
|   } | ||||
|    | ||||
|   element.elmt( | ||||
|   | ||||
| @@ -11,11 +11,11 @@ | ||||
| /// | ||||
| /// #example(`#util.lpad("0100", 8)`, mode: "markup") | ||||
| /// | ||||
| /// - s (str): The string to pad | ||||
| /// - string (str): The string to pad | ||||
| /// - len (int): The target length | ||||
| /// -> str | ||||
| #let lpad(s, len) = { | ||||
|   let res = "0" * len + s | ||||
| #let lpad(string, len) = { | ||||
|   let res = "0" * len + string | ||||
|   return res.slice(-len) | ||||
| } | ||||
|  | ||||
|   | ||||
| @@ -118,7 +118,7 @@ | ||||
| /// - style (str): The wire's style (see `wire-styles` for possible values) | ||||
| /// - reverse (bool): If true, the start and end points will be swapped (useful in cases where the start point depends on the end point, for example with perpendiculars) | ||||
| /// - zigzag-ratio (ratio): Position of the zigzag vertical relative to the horizontal span (only with style "zigzag") | ||||
| /// - dodge-y (int, float, length, ratio): Y position to dodge the wire to (only with style "dodge") | ||||
| /// - dodge-y (number): Y position to dodge the wire to (only with style "dodge") | ||||
| /// - dodge-sides (array): The start and end sides (going out of the connected element) of the wire (only with style "dodge") | ||||
| /// - dodge-margins (array): The start and end margins (i.e. space before dodging) of the wire (only with style "dodge") | ||||
| #let wire( | ||||
|   | ||||
		Reference in New Issue
	
	Block a user