-
-
Notifications
You must be signed in to change notification settings - Fork 38
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
feat: add decorations
library with brace
function
#227
Conversation
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 is really impressive nice work!
- Have a look at the other libs to see how they resolve their styles
- If you wrap the whole thing in a group and use a callback you can get
ctx
which hasctx.debug
so you could attach it to that. You can keep the parameter anyway as it is cool to see. - Have added a comment regarding type checking, main values to focus are coordinates. You can do it without
ctx
by usingcoordinate.resolve-system(...)
which will just return a string of the coordinate type or panics if it is invalid. - Don't worry about the debug anchors they're cool.
- If you can use something that aready exists in then yea, if not dw.
- Its alright.
Could you add a test for them? we don't have any guidlines but @johannes-wolf would be able to help if you need it.
That is exactly what I need; please, when you merge this PR, push it as new version to the package repo! |
Ok, will release 0.1.3 after this got merged. |
This looks great! Cant wait to have this merged :) |
sorry, I should've made multiple commits
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.
LGTM.
I will add tests for this in a follow-up PR.
@Beiri22 Release PR: typst/packages#165 |
This PR adds a new CeTZ library called "Decorations". Currently it only contains one function, i.e.
braces
, but I thought other decorations may also be added to the same module in the future. For example, zig-zag and coiled lines, or more complex shapes like gears.Here is a screenshot of the example I added to the manual:
A few points you may want to consider before merging:
merge-path
internally also doesn't even use thebezier
styles. I think it would be better for users if they could set styles for all braces, also including the things that are currently direct function parameters (amplitude
,pointiness
,content-offset
). I just don't have enough experience with CeTZ yet to implement that myself.brace
function takes adebug
parameter. Should this maybe just respect the canvas'sdebug
setting (if that is even possible)? It shows more specific and different information than the normaldebug
though.brace
function currently does no type and value checking of the parameters. Should some assertions be added?brace
function exposes anchors for all debug points. I guess this could potentially expose a bit too much of the internal structure and may lead to breaking changes for just slight internal refactors. The most important points are already exposed with appropriate names, so I would have no problem with removing these anchors.line-normal
function in theutil
module, which could be used in two places instead of the_rotate-around
function and may be faster or more accurate.Also just for reference, this PR started out with me experimenting on the Typst Discord here.