Skip to content

Commit

Permalink
Add angle style
Browse files Browse the repository at this point in the history
  • Loading branch information
fenjalien committed Dec 27, 2023
1 parent fa28e1e commit 57d359f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/mark.typ
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,16 @@
style.stroke = util.resolve-stroke(style.stroke)
style.stroke.thickness = util.resolve-number(ctx, style.stroke.thickness)

if "angle" in style and style.angle != none {
if type(style.angle) == angle {
style.width = calc.tan(style.angle / 2) * style.length * 2
} else {
// (angle, number)
style.length = calc.cos(style.angle.first()) * style.angle.last()
style.width = calc.sin(style.angle.first() / 2) * 2 * style.angle.last()
}
}

for (k, v) in style {
if k in ("length", "width", "inset", "sep") {
style.insert(k, if type(v) == ratio {
Expand Down
1 change: 1 addition & 0 deletions src/styles.typ
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
harpoon: false,
flip: false,
reverse: false,
angle: none,
/// If true, the mark points in the direction of the secant from
/// its base to its tip. If false, the tangent at the marks tip is used.
flex: true,
Expand Down

0 comments on commit 57d359f

Please sign in to comment.