Skip to content

Commit

Permalink
Document the canvas' transformation matrix
Browse files Browse the repository at this point in the history
  • Loading branch information
johannes-wolf committed Feb 20, 2024
1 parent 98a5d8d commit 704f8ec
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

## Misc
- The `hide` function now support an additional `bounds:` parameter to enable canvas bounds adjustment for hidden elements
- The default transformation matrix changed

## Libs
### Plot
Expand Down
12 changes: 10 additions & 2 deletions src/canvas.typ
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,13 @@

#import util: typst-length

/// Sets up a canvas for drawing on.
/// Sets up a canvas for drawing on.
///
/// The default transformation matrix of the canvas is set to:
/// $mat(1,0,0.5,0;
/// 0,-1,-0.5,0;
/// 0,0,0,0;
/// 0,0,0,1)$
///
/// - length (length,ratio): Used to specify what 1 coordinate unit is. If given a ratio, that ratio is relative to the containing elements width!
/// - body (none,array,element): A code block in which functions from `draw.typ` have been called.
Expand Down Expand Up @@ -41,7 +47,9 @@
prev: (pt: (0, 0, 0)),
em-size: measure(box(width: 1em, height: 1em), st),
style: styles.default,
// Current transform
// Current transformation matrix, a lhs coordinate system
// where z is sheared by a half x and y.
// +x = right, +y = up, +z = 1/2 (right + up)
transform:
((1, 0,+.5, 0),
(0,-1,-.5, 0),
Expand Down

0 comments on commit 704f8ec

Please sign in to comment.