#import "@preview/cetz:0.2.1"
#cetz.canvas({
import cetz.draw: *
let action-counter = counter("action")
let box(coordinates, body, order: auto, ..args) = group(..args, {
anchor("default", coordinates)
let w = 3
let h = 1.7
rect((), (rel: (w, h)), name: "a")
let offset = 0.2
let nw = "a.north-west"
line((rel: (0, -offset), to: nw), (rel: (+offset, 0), to: nw))
content("a.center", {
set block(width: 1cm * w * 0.9, height: 1cm * h * 0.8)
set align(center)
set par(leading: 0.3em)
block(pad(top: 0.3em, body))
})
let offset = 0.1
content(
(rel: (-offset, offset), to: "a.south-east"),
if order == auto {
action-counter.step()
action-counter.display()
} else { order },
anchor: "south-east",
)
copy-anchors("a")
})
box((0,0), name: "2")[two]
box((rel: (4, -3), to: "2"), name: "3")[three]
let start = (name: "2", anchor: -20deg)
let end = ("3.west")
let mid = (start, 50%, end)
line(start, (start, "-|", mid), (mid, "|-", end), end, mark: (end: ">", fill: black))
})
#Add `radius` to corners created by cetz line (perpendicular feature, right angles)
43 messages · Page 1 of 1 (latest)
Here is a more cut down version:
?r
#import "@preview/cetz:0.2.1"
#cetz.canvas({
import cetz.draw: *
let box(coordinates, ..args) = group(..args, {
anchor("default", coordinates)
let w = 3
let h = 1.7
rect((), (rel: (w, h)), name: "a")
copy-anchors("a")
})
box((0,0), name: "2")
box((rel: (4, -3), to: "2"), name: "3")
let start = (name: "2", anchor: -20deg)
let end = ("3.west")
let mid = (start, 50%, end)
line(start, (start, "-|", mid), (mid, "|-", end), end, mark: (end: ">", fill: black))
})
Yes, I would like to add this, but this has not been implemented yet.
Is there an open issue?
No.
I'm on it.
Thanks.
But it will take a while, I guess. I do not have that much free time in the next few weeks.
For which kind of cases this could work?
only for right angles?
No, all angles, also with beziers, but only in 2D space.
I'd like to implement it as a decoration function.
There is a ticket open to apply decorations via style key. Smth. like line(..., decoration: ("radius", ...))
I’ll just mention that fletcher implements this, but it isn’t as low-level as you probably want (a bulit-in edge style, not a cetz path decoration).
?r theme=light ```
#import "@preview/fletcher:0.4.2": diagram, node, edge
#diagram(
spacing: (5mm, 10mm),
node-stroke: 1pt,
node((0,0), "two"),
node((2,1), "three"),
edge((0,0), "r,d,r", "-|>", corner-radius: 5pt)
)
Ohhh, thaaat is where I saw the "l,u,r,d" thing.
Interesting. Gotta check it out. Thanks
weird. I deleted cached packages. btw, I said it in cetz, you also should import all external dependencies only once, because otherwise you could only modify one file and you would have multiple import versions of the same package. You import cetz in many files.
idk what is broken, but looks like fletcher. this is the first time I'm having these problems.
I'm shocked that the bot somehow manages to compile this. The problem is that cetz.dras.hide() is introduced in v0.2.1. And v0.2.0 is used 4 times.
@tiny carbon, do you know anything about this? Was the previous version somehow substituted/altered or something?
?r t=l
#import "@preview/cetz:0.2.0"
#cetz.canvas({
cetz.draw.hide(cetz.draw.rect((0,0), (1,1)))
})
Hide is in 0.2.0.
Do you have some local 0.2.0 install?
Oh... hold on.
(in the preview dir)
yeah...
I forgot I had this.
I also forgot that I can save them into ~/.local/share/typst/packages/preview/cetz.
That's why clearing cache didn't work.
Thanks.
But the problem with multiple imports of the same package still stands. I'm making a PR right now.