-
-
Notifications
You must be signed in to change notification settings - Fork 35
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
line: Draw line between element borders #378
Conversation
ce6d19f
to
fced1b5
Compare
src/draw/shapes.typ
Outdated
pts.first() = if first-is-elem { | ||
let elem = ctx.nodes.at(first-elem) | ||
|
||
let (a, b) = pts.slice(0, 2) | ||
element-line-intersection(ctx, elem, a, b) | ||
} else { | ||
pts.first() | ||
} | ||
|
||
// If the last coordinate is an element, test for intersection | ||
// of that element and a line from the two last coordinates of this | ||
// line strip. | ||
pts.last() = if last-is-elem { | ||
let elem = ctx.nodes.at(last-elem) | ||
|
||
let (a, b) = pts.slice(-2) | ||
element-line-intersection(ctx, elem, a, b) | ||
} else { | ||
pts.last() | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This could be done in a for loop which would be easier to read
(pts.first(), pts.last()) = for (name, a, b) in ((first-elem, ..pts.slice(0,2)), (last-elem, pts.slice(-2)) {
...
}
3171074
to
ae8dccd
Compare
ac4ac20
to
13ec259
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm having double thoughts about not using border anchors for this. If we do custom elements can define their own border instead relying on something you can't easily configure...
src/draw/shapes.typ
Outdated
/// If the first or last coordinate given is the name of an element, | ||
/// the intersection of that element and a line from the first or last | ||
/// two coordinates given is used as coordinate. This is useful to |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about "If the first or last points are given as the name of an element, that has a "default" anchor, the intersection of that element's border and the line."
I do not get what you mean. Custom elements should be able to override the behavior of how the intersection is determined? Ok, let's do that: the function calls the border anchor function with an angle calculated between the two points. With this PR the border-anchor got changed to the furthest one by default, which is correct for this case, too. |
5aec01b
to
c3c1acf
Compare
@fenjalien I suggest removing the WIP commit and pushing this as a shortcut for |
38f76f7
to
bb97d94
Compare
bb97d94
to
cfa7211
Compare
Fixes #234
If last and or first argument of
line
is an element name, use that for intersection test.Saves complete elements in
ctx.nodes
.