calcs/wood-stud-column/assets/sheet.typ
smillmorel d5ac3fca7e Add structural calculation worksheets
Collection of engineering calculation projects (Python + Typst), each with
input, calc script, tests, results, and generated PDF where available.
2026-09-21 12:19:20 -04:00

82 lines
2.1 KiB
Typst

#let navy = rgb("#1a3a5f")
#let muted = rgb("#626b73")
#let pass = rgb("#1f6b45")
#let fail = rgb("#9b2c2c")
#let calcsheet(
title: "Structural Calculation",
project: "",
prepared-by: "",
body,
) = {
set document(title: title, author: prepared-by)
set page(
paper: "us-letter",
margin: (x: 1in, top: 1.25in, bottom: 1in),
header: context {
grid(
columns: (1fr, 1fr),
align: (left, right),
image("../assets/logo.png", height: 30pt),
[#text(size: 9pt)[Project:] \
#text(size: 10pt, weight: "bold")[#project]],
)
},
footer: context {
set text(size: 8.5pt, fill: muted)
stack(
spacing: 4pt,
line(length: 100%, stroke: 0.5pt + muted),
[#prepared-by],
)
},
)
set text(font: "Libertinus Serif", size: 10pt, lang: "en")
set par(justify: true)
set heading(numbering: none)
show heading.where(level: 1): set text(size: 14pt, weight: "bold", fill: black)
show heading.where(level: 2): set text(size: 11pt, weight: "bold", fill: black)
show heading.where(level: 2): set block(above: 2em, below: 1em)
body
}
#let calcline(formula, note) = grid(
columns: (1.7fr, 1fr),
gutter: 4pt,
align: (left, left),
formula, text(size: 9pt, fill: muted, note),
)
#let check(label, demand, capacity, unit: "", ok: auto, demand-label: "Demand", capacity-label: "Capacity") = {
let utilization = demand / capacity
let passes = if ok == auto { utilization <= 1 } else { ok }
let color = if passes { pass } else { fail }
block(
breakable: false,
width: 100%,
stroke: 0.8pt + black,
inset: 8pt,
radius: 2pt,
)[
#grid(
columns: (1fr, auto),
[#text(weight: "bold")[#label]],
box(stroke: 0.8pt + color, inset: (x: 6pt, y: 2pt))[
#text(weight: "bold", fill: color)[#if passes { "OK" } else { "NOT OK" }]
],
)
#v(4pt)
#grid(
columns: (1fr, auto),
[
#demand-label: #calc.round(demand, digits: 2) #unit #h(14pt)
#capacity-label: #calc.round(capacity, digits: 2) #unit
],
[
D/C: #calc.round(utilization, digits: 2)
],
)
]
}