Schaltungstheorie brrrrrrr
All checks were successful
Build Typst PDFs (Docker) / build-typst (push) Successful in 16s

This commit is contained in:
alexander
2026-01-25 01:43:59 +01:00
parent d56fe69e9d
commit 1c7b4decdb
3 changed files with 632 additions and 20 deletions

86
src/lib/circuit.typ Normal file
View File

@@ -0,0 +1,86 @@
#import "@preview/cetz:0.4.2" as cetz
#import "@preview/zap:0.5.0" as zap
#import zap: interface
#let registerAllCustom() = {
cetz.draw.set-ctx(ctx => {
ctx.zap.style.insert("einTor", (
scale: auto,
fill: auto,
height: 3mm,
width: 6mm,
))
ctx
})
cetz.draw.set-ctx(ctx => {
ctx.zap.style.insert("zweiTor", (
scale: auto,
fill: none,
height: 10mm,
width: 10mm,
))
ctx
})
}
#let einTor(name, node, flip: false, ..params) = {
import cetz.draw: rect
import zap: component
// Drawing function
let draw(ctx, position, style) = {
rect(
(-style.width/2, -style.height/2),
(style.width/2, style.height/2),
fill: style.fill
)
if(flip) {
rect(
((style.width*0.7)/2, -(style.height)/2),
(style.width/2, style.height/2),
fill: black
)
} else {
rect(
(-(style.width)/2, -style.height/2),
(-(style.width*0.6)/2, style.height/2),
fill: black
)
}
interface((-style.width / 2, -style.height / 2), (style.width / 2, style.height / 2), io: position.len() < 2)
}
// Component call
component("einTor", name, node, draw: draw, ..params)
}
#let zweiTor(name, node, label, ..params) = {
import cetz.draw: rect, anchor, content
import zap: component
// Drawing function
let draw(ctx, position, style) = {
rect(
(-style.width/2, -style.height/2),
(style.width/2, style.height/2),
fill: style.fill
)
content((0,0), label)
anchor("in0", (-style.width/2, -style.height*0.5/2))
anchor("in1", (-style.width/2, style.height*0.5/2))
anchor("out0", (style.width/2, -style.height*0.5/2))
anchor("out1", (style.width/2, style.height*0.5/2))
interface((-style.width / 2, -style.height / 2), (style.width / 2, style.height / 2), io: false)
}
// Component call
component("zweiTor", name, node, draw: draw, ..params)
}

View File

@@ -1,4 +1,4 @@
#let bgBlock(body, fill: color) = block(body, fill:fill.lighten(80%), width: 100%, inset: (bottom: 2mm))
#let bgBlock(body, fill: color, width: 100%) = block(body, fill:fill.lighten(80%), width: width, inset: (bottom: 2mm))
#let SeperatorLine = line(length: 100%, stroke: (paint: black, thickness: 0.3mm))
#let MathAlignLeft(e) = {