diff options
| author | Laurenz <laurmaedje@gmail.com> | 2021-11-23 22:04:08 +0100 |
|---|---|---|
| committer | Laurenz <laurmaedje@gmail.com> | 2021-11-23 22:04:08 +0100 |
| commit | 8a88f71cb11565c1a78bd57f02a8df17cb2bf7a0 (patch) | |
| tree | 8802c1ff48e2be118e3872d25bd2f2c1f7a21b4a /tests/typeset.rs | |
| parent | c77c5a0f0ae6560a03a85e847006c29de9c7ae62 (diff) | |
Transformations
Diffstat (limited to 'tests/typeset.rs')
| -rw-r--r-- | tests/typeset.rs | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/tests/typeset.rs b/tests/typeset.rs index 6f85125e..289cf766 100644 --- a/tests/typeset.rs +++ b/tests/typeset.rs @@ -13,7 +13,9 @@ use typst::diag::Error; use typst::eval::{Smart, Value}; use typst::font::Face; use typst::frame::{Element, Frame, Geometry, Group, Shape, Stroke, Text}; -use typst::geom::{self, Color, Length, Paint, PathElement, RgbaColor, Sides, Size}; +use typst::geom::{ + self, Color, Length, Paint, PathElement, RgbaColor, Sides, Size, Transform, +}; use typst::image::Image; use typst::layout::layout; #[cfg(feature = "layout-cache")] @@ -465,6 +467,7 @@ fn draw_group( ctx: &Context, group: &Group, ) { + let ts = ts.pre_concat(convert_typst_transform(group.transform)); if group.clips { let w = group.frame.size.w.to_f32(); let h = group.frame.size.h.to_f32(); @@ -628,6 +631,18 @@ fn draw_image( canvas.fill_rect(rect, &paint, ts, Some(mask)); } +fn convert_typst_transform(transform: Transform) -> sk::Transform { + let Transform { sx, ky, kx, sy, tx, ty } = transform; + sk::Transform::from_row( + sx.get() as _, + ky.get() as _, + kx.get() as _, + sy.get() as _, + tx.to_f32(), + ty.to_f32(), + ) +} + fn convert_typst_paint(paint: Paint) -> sk::Paint<'static> { let Paint::Solid(Color::Rgba(c)) = paint; let mut paint = sk::Paint::default(); |
