You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have defined this function to draw nodes in a diagram:
/// Draw a block on the canvas.////// - pos (coordinate): Center coordinate of the block./// - width (int): Width of the block./// - height (int): Height of the block./// - name (none, str): Reference name for the block./// - label (content): Text to display inside the block./// ->#letnode(pos, width, height, label, name: none) = {
importcetz.draw: *
letbox-options= (
stroke: 2pt,
width: 100%,
height: 100%,
radius: 2pt,
)
get-ctx(ctx=> {
let (_, pos) =cetz.coordinate.resolve(ctx, pos)
letstart=cetz.vector.add(pos, (-width / 2, -height / 2))
letend=cetz.vector.add(start, (width, height))
content(
start,
end,
box(
..box-options,
align(center+horizon, label),
),
name: name,
)
})
}
It works fine, but then when I try to scale diagrams that make use of this function using cetz.draw.scale, I find that the size of the nodes created with this function do not change. I know it is because of the way I compute the start and end positions using cetz.vector.add. Is there a way to add these vectors using the context's transform or something?
Thanks
The text was updated successfully, but these errors were encountered:
Hi,
I have defined this function to draw nodes in a diagram:
It works fine, but then when I try to scale diagrams that make use of this function using
cetz.draw.scale
, I find that the size of the nodes created with this function do not change. I know it is because of the way I compute the start and end positions usingcetz.vector.add
. Is there a way to add these vectors using the context's transform or something?Thanks
The text was updated successfully, but these errors were encountered: