0.5.3 - #1101
Draft
johannes-wolf wants to merge 43 commits into
Draft
0.5.3#1101johannes-wolf wants to merge 43 commits into
johannes-wolf wants to merge 43 commits into
Conversation
The inset is respected by placing the anchors and must not be added to the path distance again.
To be able to call and test some cetz functions outside a canvas, provide a function that initializes a valid context object.
To be able to call and test some cetz functions outside a canvas, provide a function that initializes a valid context object.
Hi! I have found and fix a small typo/formatting issue in assertion in hobby/catmul that is triggered when you only provide one or zero points. I know this is very minor, so no pressure to approve/merge. <img width="616" height="29" alt="image" src="https://github.com/user-attachments/assets/de0591ab-03cd-49df-8cc8-c84b27cbb4a3" />
This way they can use the other functions in the file.
Currently trying to use the function `transform-rotate-aer` fails with `unknown variable: mul-mat` because it's defined in the same file but before `mul-mat`. This PR moves the transform functions to the bottom of the file to let them use other matrix functions. This also adds a test for `transform-rotate-aer`.
I added the information that the length of coordinates can be changed with `canvas(length: )` that was already present on "Canvas" and added it to "Coordinate Systems" for better visibility. Additionally, I removed the mention that the parameter also takes ratios, due to the Canvas API docs mentioning that this behaviour was deprecated
- Fix spelling mistakes in comments - Make angle into a variable - Fix rendering for angles > 90 degrees
Co-authored-by: Johannes Wolf <mail@johannes-wolf.com>
Co-authored-by: Johannes Wolf <mail@johannes-wolf.com>
Fix #794. This PR introduces a dedicated measure function for computing baseline anchors for equations. Typst 0.15 fixes baseline handling for math equations, enabling extraction of the required baseline metrics with a simple zero-width box trick.
#1127 relies on baseline propagation introduced in Typst 0.15. This PR raises the minimum compiler version to 0.15.0 and updates CI to use Typst 0.15.1.
…1132) For equations such as `$-$`, the baseline can lie below the equation's bounding box. In other cases, the baseline can lie above the equation's bounding box. This PR handles both edge cases and adds tests for them.
This PR builds on top of the path boolean work from #1091 and is the next step toward addressing #618. It adds a new `clip` function to clip path drawables against a closed clipping region: ```typst clip( clipping-region, body, mode: "inside", ... ) ``` Depending on `mode` (`"inside"` or `"outside"`), it keeps only the geometry inside or outside the `clipping-region`. The `body` parameter takes the objects you want to clip, and each path drawable inside it is clipped independently against `clipping-region`. Note that unlike paths in `clipping-region`, paths in `body` may contain both open and closed subpaths. Take `mode: "inside"` as an example. Under the hood, the `stroke` and `fill` of each path drawable in `body` are handled separately: - If its `stroke` is not `none`: subpaths (open or closed) are trimmed to keep only the portions inside the clipping region. - If its `fill` is not `none`: - Its closed subpaths together define the filled area according to `body-fill-rule`. A boolean intersection between that area and the `clipping-region` produces a newly generated, fill-only path. - Its open subpaths do not participate in the Boolean operation. `mode: "outside"` follows the same split: it retains the outside portions of stroked paths and uses a boolean difference for filled areas. To avoid repeating logic from #1091, I also reorganized the relevant Typst and Rust code into shared Typst/Rust modules. This is purely an internal cleanup and doesn't change the behavior of the existing `boolean` function. --- ### Example: string diagram of snake equation Someone on Discord asked how to draw a string diagram and came up with a solution using boolean operations ([discussion link](https://discord.com/channels/1054443721975922748/1260973060585164810/1533122580519850355)). With `clip`, we now have a more straightforward way to achieve this kind of effect. ```typst #cetz.canvas({ import cetz.draw: * let padded-anchor(name, position) = cetz.draw.group(name: name, { import cetz.draw: * let padding = 0.3 anchor("default", position) anchor("north", (position.at(0), position.at(1) + padding)) anchor("south", (position.at(0), position.at(1) - padding)) anchor("east", (position.at(0) + padding, position.at(1))) anchor("west", (position.at(0) - padding, position.at(1))) }) let path = { line("F_in", (4, 2)) bezier((4, 2), "epsilon.east", (4, 3)) bezier("epsilon.west", (2, 2), (2, 3)) bezier((2, 2), "eta.east", (2, 1)) bezier("eta.west", (0, 2), (0, 1)) line((0, 2), "F_out") } on-layer(10, { circle((1, 1), radius: 3mm, name: "eta", fill: white) content((), $eta$) circle((3, 3), radius: 3mm, name: "epsilon", fill: white) content((), $epsilon$) padded-anchor("F_in", (4, 0)) content("F_in.south", $F$) padded-anchor("F_out", (0, 4)) content("F_out.north", $F$) path }) let background(fill) = { rect( (-0.5, 0), (4.5, 4), stroke: none, fill: fill, ) } let aqua-region = { merge-path( { path line("F_out", (-0.5, 4), (-0.5, 0)) }, close: true, ) } on-layer(0, { background(lime) clip(aqua-region, background(aqua)) }) }) ``` <p align="center"> <img src="https://github.com/user-attachments/assets/01265e15-072d-4d93-bc02-77400eb1ac0c" width="400" alt="cetz" /> </p>
Adds a new `dedup: true` argument to `intersection` to deduplicate intersection points. Also fixes an issue with line-shape intersection producing duplicate points.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.