### Create a Two-Port Network Source: https://schemdraw.readthedocs.io/en/stable/classes/electrical.html Example of initializing a custom two-port element with specific input and output branches. ```python from schemdraw.elements.twoports import ElementTwoport from schemdraw.elements import Resistor twoport = ElementTwoport(input_element=Resistor(), output_element=Resistor(), box=True) ``` -------------------------------- ### Instantiate Transistor Elements Source: https://schemdraw.readthedocs.io/en/stable/classes/electrical.html Examples of initializing various transistor classes in SchemDraw. These classes support parameters like bulk contacts and body diodes. ```python from schemdraw.elements.transistors import NMos, PMos, NFet, PFet # Instantiate a vertical NMOS with a body diode nmos = NMos(diode=True) # Instantiate a PFET with bulk contact enabled pfet = PFet(bulk=True) ``` -------------------------------- ### Placing Various Components on a Breadboard Source: https://schemdraw.readthedocs.io/en/stable/elements/pictorial.html This example illustrates how to place a variety of standard electronic components onto a Schemdraw breadboard element. It shows the usage of different pictorial elements like CapacitorCeramic, LED, Diode, and Resistor, positioning them using breadboard anchor points. ```python with schemdraw.Drawing(): bb = pictorial.Breadboard().up() pictorial.CapacitorCeramic().at(bb.J1) pictorial.CapacitorMylar().at(bb.J4) pictorial.CapacitorElectrolytic().at(bb.J7) pictorial.TO92().at(bb.J10) pictorial.LED().at(bb.J13) pictorial.LEDOrange().at(bb.J16) pictorial.LEDYellow().at(bb.J19) pictorial.LEDGreen().at(bb.J22) pictorial.LEDBlue().at(bb.J25) pictorial.LEDWhite().at(bb.J28) pictorial.Diode().at(bb.F9).to(bb.F14) pictorial.Resistor().at(bb.F2).to(bb.F7) pictorial.DIP().at(bb.E18).up() ``` -------------------------------- ### Import Raw WaveJSON String Source: https://schemdraw.readthedocs.io/en/stable/elements/timing.html Uses the from_json method to parse raw WaveJSON strings, which is useful for importing examples directly from JavaScript/WaveDrom. ```python logic.TimingDiagram.from_json('''{ signal: [ { name: "clk", wave: "P......" }, { name: "bus", wave: "x.==.=x", data: ["head", "body", "tail", "data"] }, { name: "wire", wave: "0.1..0." } ]}''') ``` -------------------------------- ### Create Data Bus Connections Source: https://schemdraw.readthedocs.io/en/stable/elements/connectors.html Demonstrates drawing data bus connections using `BusConnect` and `BusLine`. `BusConnect` creates connections to individual lines within a bus, while `BusLine` extends the main bus line. Anchors `start` and `end` are available on `BusConnect`. ```python with schemdraw.Drawing(): J = elm.Header(rows=6) B = elm.BusConnect(n=6).at(J.pin1) elm.BusLine().down().at(B.end).length(3) B2 = elm.BusConnect(n=6).anchor('start').reverse() elm.Header(rows=6).at(B2.pin1).anchor('pin1') ``` -------------------------------- ### Bipolar Junction Transistor (BJT) Variations Source: https://schemdraw.readthedocs.io/en/stable/elements/electrical.html Provides examples for various BJT configurations including NPN, PNP, Schottky, and phototransistors, with options for circular representation. ```python import schemdraw.elements as elm d = schemdraw.Drawing() d.add(elm.Bjt()) d.add(elm.BjtNpn()) d.add(elm.BjtPnp()) d.add(elm.Bjt(circle=True)) d.add(elm.BjtNpn(circle=True)) d.add(elm.BjtPnp(circle=True)) d.add(elm.BjtPnp2c()) d.add(elm.BjtPnp2c(circle=True)) d.add(elm.NpnSchottky()) d.add(elm.PnpSchottky()) d.add(elm.NpnPhoto()) d.add(elm.PnpPhoto()) ``` -------------------------------- ### Defining Geometric and Connection Elements Source: https://schemdraw.readthedocs.io/en/stable/classes/electrical.html Provides examples of instantiating basic geometric elements like Rect, Dot, and Gap. These are used for structural layout and labeling within a schematic. ```python from schemdraw.elements import lines # Basic elements dot = lines.Dot(radius=0.075) gap = lines.Gap(lblloc='center') rect = lines.Rect(corner1=(0,0), corner2=(1,1)) ``` -------------------------------- ### GET /elements/style Source: https://schemdraw.readthedocs.io/en/stable/elements/electrical.html Configures the global drawing style for electrical elements, such as switching between IEEE (U.S.) and IEC (European) standards. ```APIDOC ## GET /elements/style ### Description Sets the global styling configuration for elements like Resistors and Fuses to either IEEE or IEC standards. ### Method GET ### Endpoint /elements/style ### Parameters #### Query Parameters - **style** (string) - Required - The style constant: 'STYLE_IEEE' or 'STYLE_IEC'. ### Request Example { "style": "STYLE_IEC" } ### Response #### Success Response (200) - **status** (string) - Confirmation of style update. #### Response Example { "status": "success", "current_style": "IEC" } ``` -------------------------------- ### Drawing Nixie Tubes with Schemdraw Source: https://schemdraw.readthedocs.io/en/stable/elements/electrical.html Shows how to draw Nixie tubes using Schemdraw, specifying the number of anodes, anode type, cathode type, and whether a grid is present. It includes an example of labeling each anode with a character. ```python with schemdraw.Drawing(): t = elm.NixieTube(anodes=12) for i in range(12): t.label(chr(ord('a')+i), f'anode{i}', halign='center', ofst=(0, .1)) elm.NixieTube(anodes=6, anodetype='dot', cathode='cold', grid=True).at((0, -3.5)) ``` -------------------------------- ### Draw Capacitor Network with Endpoints Source: https://schemdraw.readthedocs.io/en/stable/gallery/analog.html Shows how to specify exact start and end points for components using the endpoints method. This is useful for creating complex parallel or series capacitor networks. ```python with schemdraw.Drawing() as d: d.config(fontsize=12) C1 = elm.Capacitor().label('8nF').idot().label('a', 'left') C2 = elm.Capacitor().label('18nF') C3 = elm.Capacitor().down().label('8nF', loc='bottom') C4 = elm.Capacitor().left().label('32nF') C5 = elm.Capacitor().label('40nF', loc='bottom').dot().label('b', 'left') C6 = elm.Capacitor().endpoints(C1.end, C5.start).label('2.8nF') C7 = (elm.Capacitor().endpoints(C2.end, C5.start) .label('5.6nF', loc='center', ofst=(-.3, -.1), halign='right', valign='bottom')) ``` -------------------------------- ### Create a Basic Resistor Schematic with Schemdraw Source: https://schemdraw.readthedocs.io/en/stable/_sources/index.rst.txt This Python code snippet demonstrates how to create a simple schemdraw drawing containing a single resistor. It utilizes the schemdraw library and its elements module to define the resistor's orientation and label. The 'with schemdraw.Drawing():' context manager ensures proper drawing setup. ```python import schemdraw from schemdraw import elements as elm with schemdraw.Drawing(): elm.Resistor().right().label('1Ω') ``` -------------------------------- ### Customizing Pictorial Element Fill Color Source: https://schemdraw.readthedocs.io/en/stable/elements/pictorial.html This example demonstrates how to change the fill color of a pictorial element, specifically an LED, using the `.fill()` method. This is necessary for solid shapes like LEDs, as `.color()` only affects the outline. ```python pictorial.LED().fill('purple') ``` -------------------------------- ### Define Asynchronous Signals in TimingDiagram Source: https://schemdraw.readthedocs.io/en/stable/elements/timing.html Demonstrates how to use the 'async' parameter to define signal transitions that occur at non-integer period boundaries. The async list must contain one more element than the wave string length to define start and end points. ```python logic.TimingDiagram( {'signal': [ {'name': 'clk', 'wave': 'n......'}, {'name': 'B', 'wave': '010', 'async': [0, 1.6, 4.25, 7]}]}, risetime=.03) ``` -------------------------------- ### Draw a Multi-Element Circuit Diagram with Schemdraw Source: https://schemdraw.readthedocs.io/en/stable/_sources/index.rst.txt This Python code demonstrates how to construct a more complex circuit diagram using Schemdraw. It sequentially adds a resistor, capacitor, a connecting line, and a voltage source, specifying their positions, orientations, and labels. The example highlights how subsequent elements connect to the endpoints of previous ones. ```python import schemdraw from schemdraw import elements as elm with schemdraw.Drawing(): elm.Resistor().right().label('1Ω') elm.Capacitor().down().label('10μF') elm.Line().left() elm.SourceSin().up().label('10V') ``` -------------------------------- ### Initialize and Configure a Drawing Source: https://schemdraw.readthedocs.io/en/stable/classes/drawing.html Demonstrates how to instantiate a new Drawing object and configure its global properties such as font size, line width, and units. ```python import schemdraw from schemdraw import elements as elm d = schemdraw.Drawing() d.config(fontsize=12, lw=1.5, unit=2.5) # Add elements here d.draw() ``` -------------------------------- ### GET /api/schemdraw/logic-gates Source: https://schemdraw.readthedocs.io/en/stable/classes/index.html Retrieves the list of supported logic gate components and digital signal processing elements. ```APIDOC ## GET /api/schemdraw/logic-gates ### Description Returns the definitions for logic gates and DSP components available within the Schemdraw library. ### Method GET ### Endpoint /api/schemdraw/logic-gates ### Response #### Success Response (200) - **gates** (array) - List of logic gate classes #### Response Example { "gates": ["And", "Buf", "Not", "Or", "Schmitt", "Tristate"] } ``` -------------------------------- ### GET /logic/kmap Source: https://schemdraw.readthedocs.io/en/stable/classes/logic.html Generates a Karnaugh Map visualization based on provided input names and truth table data. ```APIDOC ## GET /logic/kmap ### Description Draws a K-Map with 2, 3, or 4 variables based on the provided truth table and grouping definitions. ### Method GET ### Endpoint /logic/kmap ### Parameters #### Query Parameters - **names** (string) - Required - 2-4 character string defining input names. - **truthtable** (list) - Required - List of tuples defining values to display in each box. - **groups** (dict) - Optional - Dictionary defining style parameters for circling groups. ### Request Example { "names": "AB", "truthtable": [("00", "1"), ("01", "0")] } ### Response #### Success Response (200) - **kmap** (object) - The rendered K-Map element. ``` -------------------------------- ### Create a Custom Integrated Circuit with Ic Source: https://schemdraw.readthedocs.io/en/stable/elements/intcircuits.html Demonstrates how to define an integrated circuit using the Ic class and IcPin objects. It shows how to specify pin names, sides, and custom anchor names for complex labels. ```python JK = elm.Ic(pins=[elm.IcPin(name='>', pin='1', side='left'), elm.IcPin(name='K', pin='16', side='left'), elm.IcPin(name='J', pin='4', side='left'), elm.IcPin(name=r'$\overline{Q}$', pin='14', side='right', anchorname='QBAR'), elm.IcPin(name='Q', pin='15', side='right')], edgepadW = .5, pinspacing=1).label('HC7476', 'bottom', fontsize=12) display(JK) ``` -------------------------------- ### POST /elements/lines/annotate Source: https://schemdraw.readthedocs.io/en/stable/classes/electrical.html Creates an annotation element, which is a curved arrow pointing from a start position to an end position with a label. ```APIDOC ## POST /elements/lines/annotate ### Description Draws a curved arrow pointing to a specific position, ending at a target position, with a label location at the tail of the arrow. ### Method POST ### Endpoint /elements/lines/annotate ### Parameters #### Request Body - **k** (float) - Optional - Control point factor. Higher k means tighter curve. - **th1** (float) - Optional - Angle at which the arc leaves start point. - **th2** (float) - Optional - Angle at which the arc leaves end point. - **arrow** (string) - Optional - Arrowhead specifier (e.g., '->', '<->'). - **arrowlength** (float) - Optional - Length of arrowhead [default: 0.25]. - **arrowwidth** (float) - Optional - Width of arrowhead [default: 0.2]. ### Request Example { "k": 0.5, "arrow": "->" } ### Response #### Success Response (200) - **id** (string) - The unique identifier of the created element. #### Response Example { "status": "success", "id": "annotate_001" } ``` -------------------------------- ### Create Basic Timing Diagram Source: https://schemdraw.readthedocs.io/en/stable/elements/timing.html Demonstrates the basic instantiation of a TimingDiagram using a dictionary of signals defined by WaveJSON syntax. ```python from schemdraw import logic logic.TimingDiagram( {'signal': [ {'name': 'A', 'wave': '0..1..01.'}, {'name': 'B', 'wave': '101..0...'}]}) ``` -------------------------------- ### GET /api/schemdraw/elements Source: https://schemdraw.readthedocs.io/en/stable/classes/index.html Retrieves the comprehensive list of available circuit elements, including sources, switches, lines, transistors, and integrated circuits. ```APIDOC ## GET /api/schemdraw/elements ### Description Provides a structured list of all available circuit elements categorized by their function, such as Sources, Switches, Lines, Transistors, and Opamps. ### Method GET ### Endpoint /api/schemdraw/elements ### Parameters #### Query Parameters - **category** (string) - Optional - Filter elements by category (e.g., 'Transistors', 'LogicGates') ### Response #### Success Response (200) - **elements** (array) - List of available element class names #### Response Example { "elements": ["SourceV", "Switch", "Bjt", "Opamp", "And", "Box"] } ``` -------------------------------- ### Create a Basic Circuit Drawing Source: https://schemdraw.readthedocs.io/en/stable Demonstrates how to initialize a drawing context and add a single resistor element with a label. This serves as the fundamental building block for constructing circuits in Schemdraw. ```python with schemdraw.Drawing(): elm.Resistor().right().label('1Ω') ``` -------------------------------- ### Configure a Relay Element Source: https://schemdraw.readthedocs.io/en/stable/classes/electrical.html Shows how to initialize a relay element with specific switch configurations and visual properties. ```python from schemdraw.elements.compound import Relay relay = Relay(switch='spdt', core=True, box=True) ``` -------------------------------- ### Initialize DSP Module Source: https://schemdraw.readthedocs.io/en/stable/elements/dsp.html Import the necessary dsp module from the schemdraw library to access signal processing elements. ```python from schemdraw import dsp ``` -------------------------------- ### Create Custom DSP Element Source: https://schemdraw.readthedocs.io/en/stable/elements/dsp.html Demonstrates how to create a generic square DSP element and apply a LaTeX label to represent a mathematical operation like integration. ```python dsp.Square().label(r'$\int$') ``` -------------------------------- ### Schemdraw SegmentText Transformation and Drawing Source: https://schemdraw.readthedocs.io/en/stable/classes/segments.html Provides methods for SegmentText to be transformed and drawn. Includes methods for flipping, reversing, drawing onto a figure, and getting the bounding box. ```python def doflip() -> None: """Vertically flip the element""" pass def doreverse(_centerx: float) -> None: """Reverse the path (flip horizontal about the centerx point)""" pass def draw(fig, transform, **style) -> None: """Draw the segment""" pass def get_bbox() -> BBox: """Get bounding box (untransformed)""" return (xmin, ymin, xmax, ymax) ``` -------------------------------- ### Using Drawing Containers Source: https://schemdraw.readthedocs.io/en/stable/classes/drawing.html Shows how to use the container context manager to group schematic elements together with a border. ```python with d.container(cornerradius=0.5, padx=1.0, pady=1.0): d.add(elm.Resistor()) d.add(elm.Capacitor()) ``` -------------------------------- ### Flowchart Blocks and Basic Connections Source: https://schemdraw.readthedocs.io/en/stable/elements/flow.html Demonstrates the basic usage of flowchart elements like Terminal, Process, and Arrow, along with configuration options. ```APIDOC ## Flowchart Blocks and Basic Connections ### Description This section shows how to use basic flowchart elements such as Terminal and Process, and connect them using Arrows. It also demonstrates configuring the drawing's font size and unit. ### Method ```python from schemdraw import flow with schemdraw.Drawing() as d: d.config(fontsize=10, unit=.5) flow.Terminal().label('Start') flow.Arrow() flow.Process().label('Do something').drop('E') flow.Arrow().right() flow.Process().label('Do something\nelse') ``` ### Parameters No specific parameters are detailed for this basic example, but it utilizes methods like `.label()` and `.drop()` on elements. ``` -------------------------------- ### Drawing Generic and Specific Vacuum Tubes with Schemdraw Source: https://schemdraw.readthedocs.io/en/stable/elements/electrical.html Demonstrates creating generic and specific vacuum tube elements like Diode, Triode, Tetrode, and Pentode using Schemdraw. It shows how to configure parameters such as cathode type, anode type, number of grids, and heater presence. Anchors for connections are also illustrated. ```python with schemdraw.Drawing(): elm.VacuumTube(cathode='cold', anodetype='narrow', grids=0, heater=False) elm.VacuumTube(cathode='none', heater=True).at((3, 0)) elm.VacuumTube(anodetype='dot', grids=2).at((6, 0)) elm.VacuumTube(grids=8).at((9, 0)) ``` ```python with schemdraw.Drawing(): elm.TubeDiode().label('TubeDiode') elm.Triode().at((3, 0)).label('Triode') elm.Tetrode().at((6, 0)).label('Tetrode') elm.Pentode().at((9, 0)).label('Pentode') elm.Pentode(strap=True).at((12.5, 0)).label('Pentode(strap=True)') ``` ```python with schemdraw.Drawing(): tube = (elm.Pentode() .label('1', 'cathode') .label('2', 'anode') .label('3', 'suppressor') .label('4', 'screen_R') .label('5', 'control') ) elm.Line().down().at(tube.cathode).length(1) elm.Line().up().at(tube.anode).length(.5) elm.Line().left().at(tube.suppressor).length(1) elm.Line().right().at(tube.screen_R).length(1) elm.Line().left().at(tube.control).length(1) ``` -------------------------------- ### Drawing Logic Gates with Schemdraw Source: https://schemdraw.readthedocs.io/en/stable/elements/logic.html Demonstrates importing and using the logic module to draw various digital logic gates. Gates define anchors for connections, and parameters like 'inputs' and 'inputnots' allow for customization. ```python from schemdraw import logic # Example of drawing a Nand gate with 3 inputs and an inverted first input # Nand(inputs=3, inputnots=[1]) ``` -------------------------------- ### Define Flowchart Elements in Schemdraw Source: https://schemdraw.readthedocs.io/en/stable/classes/flow.html Examples of initializing common flowchart elements like Box, Decision, and Terminal. These classes are used to build visual flow diagrams within a Schemdraw drawing context. ```python from schemdraw.flow import Box, Decision, Terminal, Subroutine # Initialize a standard process box box = Box(w=3, h=2) # Initialize a decision diamond with branch labels decision = Decision(w=4, h=3, N='Yes', S='No') # Initialize a start/end terminal node terminal = Terminal(w=2, h=1) # Initialize a subroutine box with specific side line spacing sub = Subroutine(w=3, h=2, s=0.4) ``` -------------------------------- ### Schemdraw Segment Base Class Methods Source: https://schemdraw.readthedocs.io/en/stable/classes/segments.html Provides common methods for segment manipulation and drawing, such as flipping, reversing, drawing on a figure, getting the bounding box, and transforming the segment. These methods are inherited by most segment types. ```python def doflip() -> None: """Vertically flip the element""" pass def doreverse(centerx: float) -> None: """Reverse the path (flip horizontal about the centerx point)""" pass def draw(fig, transform, **style) -> None: """Draw the segment Parameters: fig – schemdraw.Figure to draw on transform – Transform to apply before drawing style – Default style parameters """ pass def get_bbox() -> BBox: """Get bounding box (untransformed) Returns: Bounding box limits (xmin, ymin, xmax, ymax) """ pass def xform(transform, **style) -> SegmentBezier: """Return a new Segment that has been transformed to its global position Parameters: transform – Transformation to apply style – Style parameters from Element to apply as default """ pass ``` -------------------------------- ### Create Power Supply Circuit with SchemDraw Source: https://schemdraw.readthedocs.io/en/stable/gallery/analog.html This snippet demonstrates how to draw a power supply circuit featuring a rectifier, BJT transistors, capacitors, and resistors. It utilizes the Drawing context manager and various element positioning methods to define the circuit layout. ```python with schemdraw.Drawing() as d: d.config(inches_per_unit=.5, unit=3) D = elm.Rectifier() elm.Line().left(d.unit*1.5).at(D.N).dot(open=True).idot() elm.Line().left(d.unit*1.5).at(D.S).dot(open=True).idot() G = elm.Gap().toy(D.N).label(['–', 'AC IN', '+']) top = elm.Line().right(d.unit*3).at(D.E).idot() Q2 = elm.BjtNpn(circle=True).up().anchor('collector').label('Q2\n2n3055') elm.Line().down(d.unit/2).at(Q2.base) Q2b = elm.Dot() elm.Line().left(d.unit/3) Q1 = elm.BjtNpn(circle=True).up().anchor('emitter').label('Q1\n 2n3054') elm.Line().at(Q1.collector).toy(top.center).dot() elm.Line().down(d.unit/2).at(Q1.base).dot() elm.Zener().down().reverse().label('D2\n500mA', loc='bot').dot() G = elm.Ground() elm.Line().left().dot() elm.Capacitor(polar=True).up().reverse().label('C2\n100$\mu$F\n50V', loc='bot').dot() elm.Line().right().hold() elm.Resistor().toy(top.end).label('R1\n2.2K\n50V', loc='bot').dot() d.move(dx=-d.unit, dy=0) elm.Capacitor(polar=True).toy(G.start).flip().label('C1\n 1000$\mu$F\n50V').dot().idot() elm.Line().at(G.start).tox(D.W) elm.Line().toy(D.W).dot() elm.Resistor().right().at(Q2b.center).label('R2').label('56$\Omega$ 1W', loc='bot').dot() with d.hold(): elm.Line().toy(top.start).dot() elm.Line().tox(Q2.emitter) elm.Capacitor(polar=True).toy(G.start).label('C3\n470$\mu$F\n50V', loc='bot').dot() elm.Line().tox(G.start).hold() elm.Line().right().dot() elm.Resistor().toy(top.center).label('R3\n10K\n1W', loc='bot').dot() elm.Line().left().hold() elm.Line().right() elm.Dot(open=True) elm.Gap().toy(G.start).label(['+', '$V_{out}$', '–']) elm.Dot(open=True) elm.Line().left() ``` -------------------------------- ### Basic Flowchart Elements and Connections Source: https://schemdraw.readthedocs.io/en/stable/elements/flow.html Demonstrates the creation of basic flowchart elements like Terminal and Process blocks, along with Arrow connectors. It shows how to add labels and control the direction of elements using methods like 'drop'. ```python with schemdraw.Drawing() as d: d.config(fontsize=10, unit=.5) flow.Terminal().label('Start') flow.Arrow() flow.Process().label('Do something').drop('E') flow.Arrow().right() flow.Process().label('Do something else') ``` -------------------------------- ### RightLines Element Source: https://schemdraw.readthedocs.io/en/stable/classes/electrical.html Creates right-angle multi-line connectors. Use `at()` and `to()` methods to specify the start and end locations. The default lines are spaced to connect to pins with default spacing on Ic elements or connectors like Headers. ```APIDOC ## RightLines Element ### Description Creates right-angle multi-line connectors. Use `at()` and `to()` methods to specify starting and ending location. The default lines are spaced to provide connection to pins with default spacing on Ic element or connector such as a Header. ### Class `_schemdraw.elements.connectors.RightLines(*args, **kwargs)` ### Parameters - **n** (int) - Number of parallel lines - **dy** (float) - Distance between parallel lines [default: 0.6] ### Methods - **delta(dx: float = 0, dy: float = 0) -> Element** - Specify ending position relative to start position - **to(xy: Tuple[float, float] | Point) -> Element** - Specify ending position of RightLines ``` -------------------------------- ### OrthoLines Element Source: https://schemdraw.readthedocs.io/en/stable/classes/electrical.html Creates orthogonal multiline connectors. Use `at()` and `to()` methods to specify the start and end locations. The default lines are spaced to connect to pins with default spacing on Ic elements or connectors like Headers. ```APIDOC ## OrthoLines Element ### Description Creates orthogonal multiline connectors. Use `at()` and `to()` methods to specify starting and ending location of OrthoLines. The default lines are spaced to provide connection to pins with default spacing on Ic element or connector such as a Header. ### Class `_schemdraw.elements.connectors.OrthoLines(*args, **kwargs)` ### Parameters - **n** (int) - Number of parallel lines - **dy** (float) - Distance between parallel lines [default: 0.6] - **xstart** (float) - Fractional distance (0-1) to start vertical portion of first ortholine ### Methods - **delta(dx: float = 0, dy: float = 0) -> Element** - Specify ending position relative to start position - **to(xy: Tuple[float, float] | Point) -> Element** - Specify ending position of OrthoLines ``` -------------------------------- ### Schemdraw Dot and Idot Element Modifications Source: https://schemdraw.readthedocs.io/en/stable/classes/electrical.html Adds a dot marker to the end or start of an element. The `open` parameter controls whether the dot is open or closed. `dot` adds to the end, while `idot` adds to the input/start. ```python dot(_open : bool = False_) → Element """Add a dot to the end of the element""" ``` ```python idot(_open : bool = False_) → Element """Add a dot to the input/start of the element""" ``` -------------------------------- ### Importing Fritzing Parts with Schemdraw Source: https://schemdraw.readthedocs.io/en/stable/elements/pictorial.html Demonstrates how to import Fritzing part files (.fzpz) into Schemdraw using the FritzingPart class. It shows downloading a part from a URL and then using its connectors as anchors in a Schemdraw drawing. This requires the SVG backend. ```python schemdraw.use('svg') from urllib.request import urlretrieve part = 'https://github.com/adafruit/Fritzing-Library/raw/master/parts/Adafruit%20OLED%20Monochrome%20128x32%20SPI.fzpz' fname, msg = urlretrieve(part) with schemdraw.Drawing() as d: oled = pictorial.FritzingPart(fname) elm.Line().down().at(oled.GND).length(.5) elm.Ground() elm.Line().down().at(oled['3.3V']).color('red').length(1.5).label('3.3V', loc='left') elm.Button().at(oled.RESET) elm.Ground(lead=False) ``` -------------------------------- ### POST /schemdraw/use Source: https://schemdraw.readthedocs.io/en/stable/classes/drawing.html Switches the rendering backend between matplotlib and svg. ```APIDOC ## POST /schemdraw/use ### Description Changes the default rendering backend used by the library. ### Method POST ### Endpoint schemdraw.use ### Parameters #### Request Body - **backend** (string) - Required - 'matplotlib' or 'svg'. ### Request Example { "backend": "svg" } ### Response #### Success Response (200) - **status** (string) - Backend updated successfully. ``` -------------------------------- ### Triaxial Cable Element in Schemdraw Source: https://schemdraw.readthedocs.io/en/stable/classes/electrical.html Defines a triaxial cable element with parameters for overall length, inner and outer shield radii, lead length, and shield offset at start and end. Includes various anchors for detailed control. ```python class _schemdraw.elements.cables.Triax(_* args_, _** kwargs_): """Triaxial cable element.""" # Parameters: # length: Total length of the cable [default: 3] # radiusinner: Radius of inner guard [default: 0.3] # radiusouter: Radius of outer shield [default: 0.6] # leadlen: Distance (x) from start of center conductor to start of guard. [default: 0.6] # shieldofststart: Distance from start of inner guard to start of outer shield [default: 0.3] # shieldofstend: Distance from end of outer shield to end of inner guard [default: 0.3] pass ``` -------------------------------- ### Create Header and Jumper Elements Source: https://schemdraw.readthedocs.io/en/stable/elements/connectors.html Demonstrates the creation of a square-style Header element with multiple rows and a Jumper element to connect to its pins. The Jumper is visually distinguished with a light gray fill. ```python with schemdraw.Drawing(): J = elm.Header(cols=2, style='square') elm.Jumper().at(J.pin3).fill('lightgray') ``` -------------------------------- ### Construct a Multi-Element Circuit Source: https://schemdraw.readthedocs.io/en/stable Shows how to chain multiple circuit elements including a resistor, capacitor, line, and sinusoidal source. Each subsequent element automatically connects to the endpoint of the previous one. ```python with schemdraw.Drawing(): elm.Resistor().right().label('1Ω') elm.Capacitor().down().label('10μF') elm.Line().left() elm.SourceSin().up().label('10V') ``` -------------------------------- ### Schemdraw Element Positioning with delta and to Source: https://schemdraw.readthedocs.io/en/stable/classes/electrical.html Methods for specifying element positions. `delta` defines the end position relative to the start using dx and dy offsets. `to` specifies the absolute ending position with optional dx and dy offsets. ```python delta(_dx : float = 0_, _dy : float = 0_) → Element """Specify ending position relative to start position""" ``` ```python to(_xy : Tuple[float, float] | Point_, _dx : float = 0_, _dy : float = 0_) → Element """Specify ending position Parameters: xy – Ending position of element dx – X-offset from xy position dy – Y-offset from xy position""" ``` -------------------------------- ### Creating Enclosure Elements Source: https://schemdraw.readthedocs.io/en/stable/classes/electrical.html Shows how to use Encircle and EncircleBox to group multiple elements within a visual boundary. These elements accept a list of components and parameters for padding and styling. ```python from schemdraw.elements import lines # Example of enclosing a list of elements enc = lines.Encircle(elm_list=[elm1, elm2], padx=0.2, pady=0.2) box = lines.EncircleBox(elm_list=[elm1, elm2], cornerradius=0.3) ``` -------------------------------- ### Flowchart Layout and Direction Control Source: https://schemdraw.readthedocs.io/en/stable/elements/flow.html Explains and demonstrates how to control the layout and flow direction of flowchart elements. It shows default top-to-bottom flow, directional flow using specified directions, and the use of the 'drop' method to control arrow starting points. ```python with schemdraw.Drawing() as d: d.config(fontsize=10, unit=.5) flow.Terminal().label('Start') flow.Arrow() flow.Process().label('Step 1') flow.Arrow() flow.Process().label('Step 2').drop('E') flow.Arrow().right() flow.Connect().label('Next') flow.Terminal().label('Start').at((4, 0)) flow.Arrow().theta(-45) flow.Process().label('Step 1') flow.Arrow() flow.Process().label('Step 2').drop('E') flow.Arrow().right() flow.Connect().label('Next') ``` -------------------------------- ### POST /elements/transistors/bjt Source: https://schemdraw.readthedocs.io/en/stable/classes/electrical.html Create a Bipolar Junction Transistor element instance. ```APIDOC ## POST /elements/transistors/bjt ### Description Instantiates a Bipolar Junction Transistor (BJT) element with optional styling. ### Method POST ### Endpoint /elements/transistors/bjt ### Parameters #### Request Body - **circle** (boolean) - Optional - Draw circle around the transistor. ### Request Example { "circle": true } ### Response #### Success Response (200) - **anchors** (list) - List of available connection points: collector, emitter, base, center. #### Response Example { "status": "success", "element": "Bjt", "anchors": ["collector", "emitter", "base", "center"] } ``` -------------------------------- ### Schemdraw SegmentImage Class Source: https://schemdraw.readthedocs.io/en/stable/classes/segments.html Represents an image segment, supporting PNG or SVG formats. It can be initialized with an image source, position, dimensions, rotation, and image format. It also includes methods for flipping, reversing, drawing, getting the bounding box, and transforming the image. ```python class SegmentImage(image: str | BinaryIO, xy: Point = (0, 0), width: float = 3, height: float = 1, rotate: float = 0, imgfmt: str | None = None, zorder: int | None = None): """PNG or SVG Image""" pass def doflip() -> None: """Vertically flip the element""" pass def doreverse(centerx: float) -> None: """Reverse the image""" pass def draw(fig, transform, **style) -> None: """Draw the image""" pass def get_bbox() -> BBox: """Get bounding box (untransformed)""" pass def xform(transform, **style) -> SegmentImage: """Return a new Segment that has been transformed to its global position""" pass ``` -------------------------------- ### Parsing Logic Expressions with Schemdraw Source: https://schemdraw.readthedocs.io/en/stable/elements/logic.html Shows how to use the logicparse function from schemdraw.parsing.logic_parser to create logic diagrams from string expressions. Requires the pyparsing module. Supports spelled-out functions and symbols, with options for output labels and gate spacing. ```python from schemdraw.parsing import logicparse # Example: Parse a complex logic expression with an output label # logicparse('not ((w and x) or (y and z))', outlabel=r'$\\overline{Q}$') # Example: Parse a logic expression using symbols # logicparse('¬ (a ∨ b) & (c ⊻ d)') # Example: Adjust gate height # logicparse('(not a) and b or c', gateH=.5) ``` -------------------------------- ### Operational Amplifier (Opamp) Element Source: https://schemdraw.readthedocs.io/en/stable/elements/electrical.html Shows how to use the Opamp element, including options for inverting/non-inverting inputs, voltage supplies, and adding optional leads. ```python import schemdraw.elements as elm d = schemdraw.Drawing() d.add(elm.Opamp()) d.add(elm.Opamp(sign=False)) d.add(elm.Opamp(leads=True)) ``` -------------------------------- ### Drawing Dual and Split Vacuum Tubes with Schemdraw Source: https://schemdraw.readthedocs.io/en/stable/elements/electrical.html Illustrates the creation of dual vacuum tubes with independent configurations for left and right sides, and split-style tubes using Schemdraw. It shows how to label anchors for each side of the dual tube and use the 'split' parameter for split-style tubes. ```python with schemdraw.Drawing(): t = (elm.DualVacuumTube(grids_left=1, grids_right=3, heater=False) .label('anodeA', 'anodeA', halign='right') .label('anodeB', 'anodeB') .label('cathodeA', 'cathodeA') .label('cathodeB_R', 'cathodeB_R', halign='left') .label('gridA', 'gridA', valign='center') .label('gridB_1R', 'gridB_1R', valign='center') .label('gridB_3R', 'gridB_3R', valign='center') ) ``` ```python with schemdraw.Drawing(): tube1 = elm.Triode(split='left') elm.Line().down().at(tube1.cathode).length(1) tube2 = elm.Triode(split='right').at((2, 0)) elm.Line().down().at(tube2.cathode_R).length(1) ``` -------------------------------- ### Positioning Current Labels on Elements Source: https://schemdraw.readthedocs.io/en/stable/classes/electrical.html Demonstrates how to use the .at() method to place current labels or inline current arrows on existing circuit elements. The position can be an absolute coordinate or an element instance for automatic centering. ```python import schemdraw from schemdraw.elements import lines d = schemdraw.Drawing() res = d.add(lines.Line()) d.add(lines.CurrentLabel().at(res)) d.add(lines.CurrentLabelInline().at(res)) ``` -------------------------------- ### Schemdraw Arc3 Class for Cubic Bezier Arcs Source: https://schemdraw.readthedocs.io/en/stable/classes/electrical.html The Arc3 class implements a cubic Bezier curve for arcs, allowing precise control over the curve's shape using angles at the start and end points. Parameters include curvature factor (k), departure angles (th1, th2), and arrowhead specifications. Dependencies include the schemdraw library. ```python class _schemdraw.elements.lines.Arc3(_* args_, _** kwargs_): """Arc Element Use at and to methods to define endpoints. Arc3 is a cubic Bezier curve. Control points are set to extend the curve at the given angle for each endpoint.""" # Parameters: # k – Control point factor. Higher k means tighter curve. # th1 – Angle at which the arc leaves start point # th2 – Angle at which the arc leaves end point # arrow – arrowhead specifier, such as ‘->’, ‘<-’, ‘<->’, or ‘-o’ # arrowlength – Length of arrowhead [default: 0.25] # arrowwidth – Width of arrowhead [default: 0.2] pass ``` -------------------------------- ### POST /elements/transistors/fet Source: https://schemdraw.readthedocs.io/en/stable/classes/electrical.html Create a Field Effect Transistor (FET) element instance. ```APIDOC ## POST /elements/transistors/fet ### Description Instantiates a Field Effect Transistor (FET) element with configurable bulk, gate, and arrow properties. ### Method POST ### Endpoint /elements/transistors/fet ### Parameters #### Request Body - **bulk** (boolean) - Optional - Draw bulk contact. - **offset_gate** (boolean) - Optional - Draw gate on the source side. - **arrow** (boolean) - Optional - Draw source arrow. ### Request Example { "bulk": true, "offset_gate": false, "arrow": true } ### Response #### Success Response (200) - **anchors** (list) - List of available connection points: source, drain, gate, bulk, center. #### Response Example { "status": "success", "element": "AnalogNFet", "anchors": ["source", "drain", "gate", "bulk", "center"] } ``` -------------------------------- ### Draw ECE201-Style Circuit Source: https://schemdraw.readthedocs.io/en/stable/gallery/analog.html Demonstrates the use of hold(), tox(), and toy() methods to manage complex circuit layouts and alignment. It builds a multi-loop circuit with resistors and voltage sources. ```python with schemdraw.Drawing() as d: d.config(unit=2) with d.hold(): R1 = elm.Resistor().down().label('20Ω') V1 = elm.SourceV().down().reverse().label('120V') elm.Line().right(3).dot() elm.Line().right(3).dot() elm.SourceV().down().reverse().label('60V') elm.Resistor().label('5Ω').dot() elm.Line().right(3).dot() elm.SourceI().up().label('36A') elm.Resistor().label('10Ω').dot() elm.Line().left(3).hold() elm.Line().right(3).dot() R6 = elm.Resistor().toy(V1.end).label('6Ω').dot() elm.Line().left(3).hold() elm.Resistor().right().at(R6.start).label('1.6Ω').dot(open=True).label('a', 'right') elm.Line().right().at(R6.end).dot(open=True).label('b', 'right') ``` -------------------------------- ### Configuring SPDT Switches in Schemdraw Source: https://schemdraw.readthedocs.io/en/stable/elements/electrical.html This code illustrates how to draw Single-Pole Double-Throw (SPDT) switches in Schemdraw. It shows the basic SPDT switch and how to represent open or closed states using the 'action' parameter. ```python import schemdraw.elements as elm # Basic SPDT switch switch_spdt = elm.SwitchSpdt() # SPDT switch in open state switch_spdt_open = elm.SwitchSpdt(action='open') # SPDT switch in closed state switch_spdt_close = elm.SwitchSpdt(action='close') ``` -------------------------------- ### Connect Multiple Pins with OrthoLines Source: https://schemdraw.readthedocs.io/en/stable/elements/connectors.html Shows how to use `OrthoLines` for creating z-shaped orthogonal connections between parallel but vertically offset elements like an IC and a Header. The `xstart` parameter controls the vertical turn position. ```python with schemdraw.Drawing(): D1 = elm.Ic(pins=[elm.IcPin(name='A', side='r', slot='1/4'), elm.IcPin(name='B', side='r', slot='2/4'), elm.IcPin(name='C', side='r', slot='3/4'), elm.IcPin(name='D', side='r', slot='4/4')]) D2 = elm.Header(rows=4).at((7, -3)) elm.OrthoLines(n=4).at(D1.D).to(D2.pin1).label('OrthoLines') ``` -------------------------------- ### Drawing Coaxial and Triaxial Cables with Schemdraw Source: https://schemdraw.readthedocs.io/en/stable/elements/electrical.html Demonstrates the usage of `Coax` and `Triax` elements from Schemdraw for drawing coaxial and triaxial cables. It shows basic instantiation and how to set parameters like length, radius, and lead length. ```python Coax() ``` ```python Triax() ``` ```python Coax(length=5, radius=0.5) ``` ```python Triax(length=5, radiusinner=0.5) ``` ```python CoaxConnect ``` -------------------------------- ### Breadboard Element Anchors and Placement Source: https://schemdraw.readthedocs.io/en/stable/elements/pictorial.html Demonstrates how to use the Breadboard element in Schemdraw and place dots at specific anchor points. The anchors are named using column letters and row numbers for the main block and power strips, allowing precise component placement. ```python with schemdraw.Drawing(): bb = pictorial.Breadboard() elm.Dot(radius=.15).at(bb.A1).color('red') elm.Dot(radius=.15).at(bb.H10).color('orange') elm.Dot(radius=.15).at(bb.L1_1).color('cyan') elm.Dot(radius=.15).at(bb.R2_7).color('magenta') elm.Dot(radius=.15).at(bb.L2_13).color('green') ``` -------------------------------- ### POST /schemdraw/config Source: https://schemdraw.readthedocs.io/en/stable/classes/drawing.html Configures global settings for the Schemdraw environment, including units, fonts, colors, and line styles. ```APIDOC ## POST /schemdraw/config ### Description Sets global configuration parameters for the drawing environment, such as unit scaling, font properties, and default colors. ### Method POST ### Endpoint schemdraw.config ### Parameters #### Request Body - **unit** (float) - Optional - Full length of a 2-terminal element. - **inches_per_unit** (float) - Optional - Inches per drawing unit for scaling. - **fontsize** (float) - Optional - Default font size for text labels. - **font** (string) - Optional - Default font family. - **color** (string) - Optional - Default color name or RGB tuple. - **lw** (float) - Optional - Default line width. ### Request Example { "unit": 3.0, "fontsize": 14.0, "color": "black" } ### Response #### Success Response (200) - **status** (string) - Configuration applied successfully. ``` -------------------------------- ### Audio Elements: Speaker, Microphone, and Jack Source: https://schemdraw.readthedocs.io/en/stable/elements/electrical.html Demonstrates the usage of Speaker, Microphone, and AudioJack elements. The AudioJack can be configured with ring, switch, and ring-switch options to represent different jack types. ```python import schemdraw.elements as elm d = schemdraw.Drawing() d.add(elm.Speaker()) d.add(elm.Mic()) d.add(elm.AudioJack()) d.add(elm.AudioJack(ring=True)) d.add(elm.AudioJack(switch=True)) d.add(elm.AudioJack(switch=True, ring=True, ringswitch=True)) ```