Compare commits
No commits in common. "99b90377196d23918b75d7635a7d87f129d2040c" and "8bcedbfc534a2745137bdea0735ba466d06580c1" have entirely different histories.
99b9037719
...
8bcedbfc53
@ -24,7 +24,6 @@
|
||||
/// - width (float): TODO -> remove
|
||||
/// - height (float): TODO -> remove
|
||||
/// - full-page (bool): If true, the page will be resized to fit the diagram and take the background color
|
||||
/// - all-bit-i (bool): If true, all bit indices will be rendered, otherwise, only the ends of each range will be displayed
|
||||
/// -> dictionary
|
||||
#let config(
|
||||
default-font-family: "Ubuntu Mono",
|
||||
@ -50,8 +49,7 @@
|
||||
left-labels: false,
|
||||
width: 1200,
|
||||
height: 800,
|
||||
full-page: false,
|
||||
all-bit-i: true
|
||||
full-page: false
|
||||
) = {}
|
||||
|
||||
/// Dark theme config
|
||||
|
@ -11,5 +11,4 @@
|
||||
/// This functions
|
||||
/// - structures (dictionary): A schema dictionary, as returned by #doc-ref("schema.load")
|
||||
/// - config (auto, dictionary): The configuration parameters, as returned by #doc-ref("config.config")
|
||||
/// - width (ratio, length): The width of the generated figure
|
||||
#let render(structures, config: auto, width: 100%) = {}
|
||||
#let render(structures, config: auto)
|
BIN
manual.pdf
BIN
manual.pdf
Binary file not shown.
@ -22,8 +22,7 @@
|
||||
left-labels: false,
|
||||
width: 1200,
|
||||
height: 800,
|
||||
full-page: false,
|
||||
all-bit-i: true
|
||||
full-page: false
|
||||
) = {
|
||||
return (
|
||||
default-font-family: default-font-family,
|
||||
@ -49,8 +48,7 @@
|
||||
left-labels: left-labels,
|
||||
width: width,
|
||||
height: height,
|
||||
full-page: full-page,
|
||||
all-bit-i: all-bit-i
|
||||
full-page: full-page
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
#let version = version((0,0,2))
|
||||
#let version = version((0,0,1))
|
||||
|
||||
#import "config.typ"
|
||||
#import "schema.typ"
|
@ -356,27 +356,14 @@
|
||||
// Draw rectangle around structure
|
||||
shapes += draw-rect(border-col, bits-x, bits-y, bits-width, bit-h, thickness: 2)
|
||||
|
||||
let indices = range(struct.bits)
|
||||
if not config.all-bit-i {
|
||||
indices = ()
|
||||
for r in struct.ranges.values() {
|
||||
indices.push(r.start)
|
||||
indices.push(r.end)
|
||||
}
|
||||
}
|
||||
|
||||
for i in range(struct.bits) {
|
||||
let bit-x = ox + i * bit-w
|
||||
let real-i = struct.bits - i - 1 + start-bit
|
||||
|
||||
if real-i in indices {
|
||||
shapes += draw-text(
|
||||
str(real-i),
|
||||
str(struct.bits - i - 1 + start-bit),
|
||||
txt-col,
|
||||
bit-x + bit-w / 2,
|
||||
oy + bit-h / 2
|
||||
)
|
||||
}
|
||||
|
||||
// Draw separator
|
||||
if i != 0 {
|
||||
@ -446,7 +433,7 @@
|
||||
return (shapes, desc-y)
|
||||
}
|
||||
|
||||
#let render(config, structures, width: 100%) = {
|
||||
#let render(config, structures) = {
|
||||
set text(
|
||||
font: config.default-font-family,
|
||||
size: config.default-font-size
|
||||
@ -471,7 +458,7 @@
|
||||
|
||||
set page(..params)
|
||||
|
||||
let cnvs = canvas(length: 1pt, background: config.background, {
|
||||
canvas(length: 1pt, background: config.background, {
|
||||
let (shapes, _) = draw-structure(
|
||||
config, main, structures,
|
||||
ox: ox,
|
||||
@ -488,32 +475,6 @@
|
||||
fill: none
|
||||
)
|
||||
})
|
||||
|
||||
layout(size => {
|
||||
let m = measure(cnvs)
|
||||
let w = m.width
|
||||
let h = m.height
|
||||
let base-w = if type(width) == ratio {
|
||||
size.width * width
|
||||
} else {
|
||||
width
|
||||
}
|
||||
let r = if w == 0 {
|
||||
0
|
||||
} else {
|
||||
base-w / w
|
||||
}
|
||||
|
||||
let new-w = w * r
|
||||
let new-h = h * r
|
||||
r *= 100%
|
||||
|
||||
box(
|
||||
width: new-w,
|
||||
height: new-h,
|
||||
scale(x: r, y: r, cnvs, reflow: true)
|
||||
)
|
||||
})
|
||||
}
|
||||
|
||||
#let make(config) = {
|
||||
|
@ -56,10 +56,10 @@
|
||||
return structures
|
||||
}
|
||||
|
||||
#let render(structures, width: 100%, config: auto) = {
|
||||
#let render(structures, config: auto) = {
|
||||
if config == auto {
|
||||
config = conf.config()
|
||||
}
|
||||
let renderer_ = renderer.make(config)
|
||||
(renderer_.render)(structures, width: width)
|
||||
(renderer_.render)(structures)
|
||||
}
|
@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "rivet"
|
||||
version = "0.0.2"
|
||||
version = "0.0.1"
|
||||
compiler = "0.11.0"
|
||||
repository = "https://git.kb28.ch/HEL/rivet-typst"
|
||||
entrypoint = "src/lib.typ"
|
||||
|
Loading…
Reference in New Issue
Block a user