Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mark: Mark auto offsetting #314

Merged
merged 11 commits into from
Nov 10, 2023
Merged

mark: Mark auto offsetting #314

merged 11 commits into from
Nov 10, 2023

Conversation

johannes-wolf
Copy link
Member

@johannes-wolf johannes-wolf commented Nov 4, 2023

This is work in progress.

Changes: Remove mark.size in favor of mark.width and mark.length + mark.scale.

  • width: The width of the mark measured at the base (or mid)
  • length: The length of the mark on the path
  • scale: A factor that scales width and length to make it easy changing mark size without having to (re-) calculate ratio
  • inset: (filled triangles and harpoons) Sets the base inset to create an arrow-head like mark
  • sep: Extra space between multiple marks
  • bezier & catmull shorten: Bézier shorting mode "LINEAR" or "CURVED", use linear or curved offsetting
  • bezier & catmull flex: If true, the mark points in the direction of the secant between its base and tip (default: true)
  • You can now place multiple marks using (">", ">") arrays instead of a single symbol string.
  • New left-harpoon and right-harpoon marks
  • Circle marks ("o") now use their border as tip (before it was the center)
  • Catmull curves now support marks (limitation: only the first segment is used)
  • Arcs now allso support marks :)

This tries to mirror TikZ main mark size related attributes.

@fenjalien You wanted to change how marks work, what is your plan?

Fixes #247
Fixes #239
Fixes #218

Copy link
Member

@fenjalien fenjalien left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wow I cannot believe how good this is :D

  • I don't understand the purpose of scale, could you link its tikz alternative?
  • Would it be possible to generalise the mark placement functions to work on path drawables? Then they can just modify the drawables to shorten them?

This is a great start and covers a lot of what I wanted to address. However I think there could be many more options/stuff brought over. This PR is already a good size though so it should go into a new one. Do you want me to make an issue detailing all the options we could have?

src/bezier.typ Outdated Show resolved Hide resolved
src/bezier.typ Outdated Show resolved Hide resolved
src/bezier.typ Outdated Show resolved Hide resolved
src/bezier.typ Show resolved Hide resolved
src/draw/shapes.typ Outdated Show resolved Hide resolved
src/mark.typ Outdated
return -width / 2
}

return 0
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unreachable

src/mark.typ Show resolved Hide resolved
src/mark.typ Outdated
Comment on lines 76 to 77
// Get mark symbol mid length, that is the length from the tip to the mid-point
// of its base. For triangular shaped marks, that is the length minus the inset.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so the distance between the inset and the tip?

src/mark.typ Outdated
///
/// - ctx (context): Context
/// - pts (array): Array of vectors
/// - marks (style): Mark style dictionary
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

call this style

@@ -1,4 +1,6 @@
// This file contains utility functions for path calculation
#let typst-length = length
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can this go in util.typ?

@johannes-wolf
Copy link
Member Author

johannes-wolf commented Nov 5, 2023

Wow I cannot believe how good this is :D

* I don't understand the purpose of `scale`, could you link its tikz alternative?

It is here: https://tikz.dev/tikz-arrows#sec-16.3.2 - A factor that gets applied on all size-related (length, width, inset) attributes.

* Would it be possible to generalise the mark placement functions to work on path drawables? Then they can just modify the drawables to shorten them?

Yes, I will add that. It is not that easy, I'd like to do this in a separate PR.

This is a great start and covers a lot of what I wanted to address. However I think there could be many more options/stuff brought over. This PR is already a good size though so it should go into a new one. Do you want me to make an issue detailing all the options we could have?

Yes, that would be nice.

@johannes-wolf
Copy link
Member Author

I applied the review annotations.

@johannes-wolf
Copy link
Member Author

johannes-wolf commented Nov 10, 2023

  • Fixed vector.coss (oops) and marks pointing to +/- z
  • Fixed matrix.transform-rotate-xyz

#let transform-rotate-xyz(x, y, z) = {
// let (pi, cos, sin) = (calc.pi, calc.cos, calc.sin)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was wrong.

src/bezier.typ Outdated Show resolved Hide resolved
@johannes-wolf johannes-wolf merged commit 08bc87a into 0.2.0 Nov 10, 2023
0 of 2 checks passed
@johannes-wolf johannes-wolf deleted the shorten-cubic branch November 10, 2023 18:17
@fenjalien fenjalien mentioned this pull request Nov 12, 2023
54 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants