Skip to content

Commit

Permalink
Bug fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
fenjalien committed Dec 27, 2023
1 parent 57d359f commit 75972d7
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 27 deletions.
2 changes: 1 addition & 1 deletion src/draw/shapes.typ
Original file line number Diff line number Diff line change
Expand Up @@ -1244,7 +1244,7 @@
path.segments = segments
path = (path,) + marks
}

// panic(drawables)
return (
ctx: ctx,
name: name,
Expand Down
1 change: 1 addition & 0 deletions src/drawable.typ
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
return ()
}
for drawable in drawables {
assert(type(drawable) != array, message: repr(drawables))
if drawable.type == "path" {
drawable.segments = drawable.segments.map(s => {
return (s.at(0),) + util.apply-transform(transform, ..s.slice(1))
Expand Down
42 changes: 16 additions & 26 deletions src/mark.typ
Original file line number Diff line number Diff line change
Expand Up @@ -115,14 +115,15 @@
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()
}
if "angle" in style and type(style.angle) == angle {
// if type(style.angle) == angle {
style.width = calc.tan(style.angle / 2) * style.length * 2
// } else {
// // (angle, number)
// Tikz gives an example of (90deg, 10pt) but this causes the length to be 0 but does not show that.
// 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 {
Expand Down Expand Up @@ -180,21 +181,6 @@
/// -> A dictionary with the keys:
/// - drawables (drawables): The transformed drawables of the mark.
/// - distance: The distance between the tip of the mark and the end.
#let place-mark(style, pos, angle) = {
let (drawables, distance, tip-offset) = (marks.at(style.symbol))(style)

return (
drawables: drawable.apply-transform(
matrix.mul-mat(
matrix.transform-translate(..pos),
matrix.transform-rotate-z(angle),
matrix.transform-translate(tip-offset, 0, 0)
),
drawables
),
distance: distance + tip-offset
)
}

#let place-mark-on-path(ctx, styles, segments, is-end: false) = {
if type(styles) != array {
Expand Down Expand Up @@ -285,9 +271,13 @@
distance.last() = end-distance
}
if distance != (0, 0) {
segments = path-util.shorten-path(segments, ..distance, mode: if style.flex { "CURVED" } else { "LINEAR" }, samples: style.position-samples)
segments = path-util.shorten-path(
segments,
..distance,
mode: if style.flex { "CURVED" } else { "LINEAR" },
samples: style.position-samples
)
}

return (drawables, segments)

}
}

0 comments on commit 75972d7

Please sign in to comment.