diff --git a/src/draw/styling.typ b/src/draw/styling.typ index 95e62ba1c..2783ede97 100644 --- a/src/draw/styling.typ +++ b/src/draw/styling.typ @@ -40,20 +40,20 @@ /// register-mark(":)", style => { /// circle((0,0), radius: .5, fill: yellow) /// arc((0,0), start: 180deg + 30deg, delta: 180deg - 60deg, anchor: "origin", radius: .3) -/// circle((-.15, +.15), radius: .1, fill: white) -/// circle((-.10, +.10), radius: .025, fill: black) -/// circle((+.15, +.15), radius: .1, fill: white) -/// circle((+.20, +.10), radius: .025, fill: black) +/// circle((-0.15, 0.15), radius: .1, fill: white) +/// circle((-0.10, 0.10), radius: .025, fill: black) +/// circle(( 0.15, 0.15), radius: .1, fill: white) +/// circle(( 0.20, 0.10), radius: .025, fill: black) /// -/// anchor("tip", (+.5, 0)) -/// anchor("base", (-.5, 0)) +/// anchor("tip", ( 0.5, 0)) +/// anchor("base", (-0.5, 0)) /// }) /// /// line((0,0), (3,0), mark: (end: ":)")) /// ``` /// -/// - symbol (string): Mark name -/// - mnemonic (none,string): Mark short name +/// - symbol (str): Mark name +/// - mnemonic (none,str): Mark short name /// - body (function): Mark drawing callback, receiving the mark style as argument and returning elements. Format `(styles) => elements`. #let register-mark(symbol, body, mnemonic: none) = { assert(type(symbol) == str) diff --git a/src/mark-shapes.typ b/src/mark-shapes.typ index b293749c5..dbefc82fe 100644 --- a/src/mark-shapes.typ +++ b/src/mark-shapes.typ @@ -91,6 +91,7 @@ triangle-tip-base(style, (0, 0), (style.length, 0)) }, + // A mark in the shape of an arrow tip. stealth: (style) => { import "/src/draw.typ": * @@ -201,6 +202,7 @@ tip-base(style, (-r, 0), (l - r, 0), center: ((-r + i) / 2, 0)) }, + // An unfilled mark in the shape of an angle bracket (>). straight: (style) => { import "/src/draw.typ": * @@ -222,7 +224,6 @@ let (l, w) = (style.length, style.width) - // Force join to "round" as other joins look bad let ctrl-a = (l, 0) let ctrl-b = (0, 0) diff --git a/src/mark.typ b/src/mark.typ index af20fa981..8e928464b 100644 --- a/src/mark.typ +++ b/src/mark.typ @@ -117,12 +117,12 @@ mark.offset = vector.dist(origin, tip) let t = ( - /* Translate & rotate to the target coordinate & direction */ + // Translate & rotate to the target coordinate & direction matrix.transform-translate(..pos), matrix.transform-rotate-dir(dir, up), matrix.transform-rotate-z(-90deg), - /* Apply mark transformations */ + // Apply mark transformations if reverse { matrix.transform-translate(-mark.length, 0, 0) }, @@ -158,7 +158,7 @@ return mark } -#let _eval-mark(ctx, mark, style) = { +#let _eval-mark-shape-and-anchors(ctx, mark, style) = { if "eval-mark-guard" in ctx { panic("Recursive mark drawing is not allowed") } @@ -258,7 +258,7 @@ style = merge-flag(style, "flip") style = merge-flag(style, "harpoon") - let mark = _eval-mark(ctx, mark-fn(style), style) + let mark = _eval-mark-shape-and-anchors(ctx, mark-fn(style), style) let pos = if style.flex { path-util.point-on-path(