summaryrefslogtreecommitdiff
path: root/crates/typst-library/src/layout/transform.rs
diff options
context:
space:
mode:
authorLaurenz Stampfl <47084093+LaurenzV@users.noreply.github.com>2025-04-01 16:42:52 +0200
committerGitHub <noreply@github.com>2025-04-01 14:42:52 +0000
commit96dd67e011bb317cf78683bcf1edfdfca5e7b6b3 (patch)
tree900a0c4e7723af4289685af35d788041055ad4a2 /crates/typst-library/src/layout/transform.rs
parent012e14d40cb44997630cf6469a446f217f2e9057 (diff)
Switch PDF backend to `krilla` (#5420)
Co-authored-by: Laurenz <laurmaedje@gmail.com>
Diffstat (limited to 'crates/typst-library/src/layout/transform.rs')
-rw-r--r--crates/typst-library/src/layout/transform.rs14
1 files changed, 14 insertions, 0 deletions
diff --git a/crates/typst-library/src/layout/transform.rs b/crates/typst-library/src/layout/transform.rs
index 183df609..d153d97d 100644
--- a/crates/typst-library/src/layout/transform.rs
+++ b/crates/typst-library/src/layout/transform.rs
@@ -307,6 +307,20 @@ impl Transform {
Self { sx, sy, ..Self::identity() }
}
+ /// A scale transform at a specific position.
+ pub fn scale_at(sx: Ratio, sy: Ratio, px: Abs, py: Abs) -> Self {
+ Self::translate(px, py)
+ .pre_concat(Self::scale(sx, sy))
+ .pre_concat(Self::translate(-px, -py))
+ }
+
+ /// A rotate transform at a specific position.
+ pub fn rotate_at(angle: Angle, px: Abs, py: Abs) -> Self {
+ Self::translate(px, py)
+ .pre_concat(Self::rotate(angle))
+ .pre_concat(Self::translate(-px, -py))
+ }
+
/// A rotate transform.
pub fn rotate(angle: Angle) -> Self {
let cos = Ratio::new(angle.cos());