Skip to content

Commit

Permalink
Review stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
johannes-wolf committed Aug 24, 2024
1 parent f48d9c3 commit c8913ef
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 13 deletions.
16 changes: 8 additions & 8 deletions src/draw/styling.typ
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
3 changes: 2 additions & 1 deletion src/mark-shapes.typ
Original file line number Diff line number Diff line change
Expand Up @@ -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": *

Expand Down Expand Up @@ -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": *

Expand All @@ -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)

Expand Down
8 changes: 4 additions & 4 deletions src/mark.typ
Original file line number Diff line number Diff line change
Expand Up @@ -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)
},
Expand Down Expand Up @@ -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")
}
Expand Down Expand Up @@ -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(
Expand Down

0 comments on commit c8913ef

Please sign in to comment.