diff --git a/CHANGES.md b/CHANGES.md index 7fc69644..e0267d08 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -4,6 +4,8 @@ CeTZ 0.3.0 requires Typst 0.11.0 ## Canvas - Transformation matrices are now rounded +- The default coordinate system changed to a right-hand side system. + Use `scale(z: -1)` if you want to change back to a left-hand system. ## Plot - Added support for automatically adding axis breaks (sawtooth lines) by setting the `break` diff --git a/src/canvas.typ b/src/canvas.typ index fc4e7941..d587c279 100644 --- a/src/canvas.typ +++ b/src/canvas.typ @@ -11,10 +11,10 @@ /// 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)$ +/// $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. @@ -45,12 +45,12 @@ // Previous element position & bbox prev: (pt: (0, 0, 0)), style: styles.default, - // Current transformation matrix, a lhs coordinate system + // Current transformation matrix, a rhs coordinate system // where z is sheared by a half x and y. - // +x = right, +y = up, +z = 1/2 (right + up) + // +x = right, +y = up, +z = 1/2 (left + down) transform: - ((1, 0,+.5, 0), - (0,-1,-.5, 0), + ((1, 0,-.5, 0), + (0,-1,+.5, 0), (0, 0, .0, 0), (0, 0, .0, 1)), // Nodes, stores anchors and paths diff --git a/tests/arc/arc-through/ref/1.png b/tests/arc/arc-through/ref/1.png index e8397837..64db0f87 100644 Binary files a/tests/arc/arc-through/ref/1.png and b/tests/arc/arc-through/ref/1.png differ diff --git a/tests/arc/ref/1.png b/tests/arc/ref/1.png index 382eb64d..10dcda4c 100644 Binary files a/tests/arc/ref/1.png and b/tests/arc/ref/1.png differ diff --git a/tests/content/ref/1.png b/tests/content/ref/1.png index 460765a2..f0b66782 100644 Binary files a/tests/content/ref/1.png and b/tests/content/ref/1.png differ diff --git a/tests/content/transform/ref/1.png b/tests/content/transform/ref/1.png index 444c94a6..b769e4a0 100644 Binary files a/tests/content/transform/ref/1.png and b/tests/content/transform/ref/1.png differ diff --git a/tests/cube/ref/1.png b/tests/cube/ref/1.png index b5ef7685..1e593aaf 100644 Binary files a/tests/cube/ref/1.png and b/tests/cube/ref/1.png differ diff --git a/tests/decorations/path/ref/1.png b/tests/decorations/path/ref/1.png index 77c61a2b..4789705f 100644 Binary files a/tests/decorations/path/ref/1.png and b/tests/decorations/path/ref/1.png differ diff --git a/tests/projection/default/ref/1.png b/tests/projection/default/ref/1.png new file mode 100644 index 00000000..1eb21489 Binary files /dev/null and b/tests/projection/default/ref/1.png differ diff --git a/tests/projection/default/test.typ b/tests/projection/default/test.typ new file mode 100644 index 00000000..37e88876 --- /dev/null +++ b/tests/projection/default/test.typ @@ -0,0 +1,23 @@ +#import "/src/lib.typ" as cetz +#import "/tests/helper.typ": * +#set page(width: auto, height: auto) + +// Positive direction +#test-case({ + import cetz.draw: * + + set-style(mark: (transform-shape: false)) + line((0,0,0), (1,0,0), mark: (end: ">")) + line((0,0,0), (0,1,0), mark: (end: ">")) + line((0,0,0), (0,0,1), mark: (end: ">")) +}) + +// Negative direction +#test-case({ + import cetz.draw: * + + set-style(mark: (transform-shape: false)) + line((0,0,0), (-1,0,0), mark: (end: ">")) + line((0,0,0), (0,-1,0), mark: (end: ">")) + line((0,0,0), (0,0,-1), mark: (end: ">")) +})