Skip to content

Commit

Permalink
mark: Add barbed mark
Browse files Browse the repository at this point in the history
  • Loading branch information
johannes-wolf committed Dec 21, 2023
1 parent b85b288 commit 989649a
Showing 1 changed file with 26 additions and 4 deletions.
30 changes: 26 additions & 4 deletions src/mark-shapes.typ
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,11 @@
// See: https://svgwg.org/svg2-draft/painting.html#LineJoin
if style.stroke.join == "miter" {
let angle = calc.abs(angle)
let miter-limit = 1 / calc.sin(angle / 2)
if miter-limit <= style.stroke.miter-limit {
return miter-limit * (style.stroke.thickness / 2)
if angle > 0deg {
let miter-limit = 1 / calc.sin(angle / 2)
if miter-limit <= style.stroke.miter-limit {
return miter-limit * (style.stroke.thickness / 2)
}
}
}

Expand All @@ -47,7 +49,6 @@
})
}


// Dictionary of built-in mark styles
//
// (style) => (drawables:, tip-offset:, distance:)
Expand Down Expand Up @@ -224,6 +225,27 @@
distance: style.length,
inset: style.length
),
barbed: (style) => {
// Force join to "round" as other joins look bad
style.stroke.join = "round"
let ctrl-a = (style.length, 0)
let ctrl-b = (0, 0)
(drawables: drawable.path(
(path-util.cubic-segment(
(style.length, style.width / 2), (0,0),
ctrl-a, ctrl-b),)
+ if not style.harpoon {
(path-util.cubic-segment(
(0,0), (style.length, -style.width / 2),
ctrl-b, ctrl-a),)
} else { () },
close: false,
fill: none,
stroke: style.stroke),
tip-offset: calculate-tip-offset(style),
distance: style.length,
inset: style.length
)},
plus: (style) => (
drawables: _star-shape(4, style),
tip-offset: 0,
Expand Down

0 comments on commit 989649a

Please sign in to comment.