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

Streamline Angle API Behaviour #729

Merged
merged 2 commits into from
Oct 29, 2024
Merged

Streamline Angle API Behaviour #729

merged 2 commits into from
Oct 29, 2024

Conversation

johannes-wolf
Copy link
Member

Angles are now always drawn counter-clock-wise.

Fixes #712

@johannes-wolf johannes-wolf added the bug 🐛 Something isn't working label Oct 19, 2024
@johannes-wolf johannes-wolf added this to the 0.3.2 milestone Oct 19, 2024
@knuesel
Copy link

knuesel commented Oct 22, 2024

Thanks! With that PR and the following code:

#let trig-angle(alpha) = cetz.canvas(length: 1.8cm, {
  import cetz.draw: *

  let O = (0, 0)
  let P = (1, 0)
  let Q = (alpha, 1)

  line(O, P, mark: (end: ">"))
  line(O, Q, mark: (end: ">"))
  content((P, -6pt, O), $P$)
  content((Q, -6pt, O), $Q$)

  cetz.angle.angle(O, P, Q, mark: (end: ">"), label: [#alpha], label-radius: 170%)
  rect((-1, 0), (1, 0), stroke: none) // for bounding box
})

#for alpha in (60deg, 240deg, -60deg, -240deg) {
  box(trig-angle(alpha))
}

I get this:

image

and if I add inner: false I get:

image

so the functionality is perfect for my use case.

I have two concerns though:

  1. The keyword name inner doesn't make sense now
  2. Other users might miss the previous functionality (having an easy way to choose between "short" and "long" path for the angle)

What about replacing inner with a direction keyword, with the following possible values:

  • "clockwise"
  • "counter-clockwise"
  • "near"
  • "far"

I think this way it would be easy to achieve the desired result in all common use cases. What do you think?

@johannes-wolf
Copy link
Member Author

johannes-wolf commented Oct 27, 2024

I've changed inner: to direction: with the values "cw" and "ccw".

@knuesel
Copy link

knuesel commented Oct 29, 2024

Excellent! I think that new API is great and something like "near"/"far" could be added later if there's demand for it.

@johannes-wolf johannes-wolf merged commit 90f6935 into master Oct 29, 2024
1 check passed
@johannes-wolf johannes-wolf deleted the 712-angle-lib-api branch October 29, 2024 17:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐛 Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

angle results are hard to predict and control
2 participants