mirror of
https://github.com/typst/typst
synced 2025-05-18 02:55:28 +08:00
Fix PDF transform (#2850)
This commit is contained in:
parent
b8b1a92151
commit
f5c90c8714
@ -1,7 +1,7 @@
|
||||
use ecow::eco_format;
|
||||
use pdf_writer::types::{ColorSpaceOperand, PaintType, TilingType};
|
||||
use pdf_writer::{Filter, Finish, Name, Rect};
|
||||
use typst::layout::{Abs, Transform};
|
||||
use typst::layout::{Abs, Ratio, Transform};
|
||||
use typst::util::Numeric;
|
||||
use typst::visualize::{Pattern, RelativeTo};
|
||||
|
||||
@ -73,7 +73,9 @@ pub(crate) fn write_patterns(ctx: &mut PdfContext) {
|
||||
|
||||
resources_map.finish();
|
||||
tiling_pattern
|
||||
.matrix(transform_to_array(*transform))
|
||||
.matrix(transform_to_array(
|
||||
transform.post_concat(Transform::scale(Ratio::one(), -Ratio::one())),
|
||||
))
|
||||
.filter(Filter::FlateDecode);
|
||||
}
|
||||
}
|
||||
|
BIN
tests/ref/visualize/pattern-simple.png
Normal file
BIN
tests/ref/visualize/pattern-simple.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 343 B |
18
tests/typ/visualize/pattern-simple.typ
Normal file
18
tests/typ/visualize/pattern-simple.typ
Normal file
@ -0,0 +1,18 @@
|
||||
// Tests that simple patterns work.
|
||||
|
||||
---
|
||||
#set page(width: auto, height: auto, margin: 0pt)
|
||||
#let pat = pattern(size: (10pt, 10pt), line(stroke: 4pt, start: (0%, 0%), end: (100%, 100%)))
|
||||
#rect(width: 50pt, height: 50pt, fill: pat)
|
||||
|
||||
---
|
||||
#set page(width: auto, height: auto, margin: 0pt)
|
||||
|
||||
#let pat = pattern(size: (10pt, 10pt), {
|
||||
place(line(stroke: 4pt, start: (0%, 0%), end: (100%, 100%)))
|
||||
place(line(stroke: 4pt, start: (100%,0%), end: (200%, 100%)))
|
||||
place(line(stroke: 4pt, start: (0%,100%), end: (100%, 200%)))
|
||||
place(line(stroke: 4pt, start: (-100%,0%), end: (0%, 100%)))
|
||||
place(line(stroke: 4pt, start: (0%,-100%), end: (100%, 0%)))
|
||||
})
|
||||
#rect(width: 50pt, height: 50pt, fill: pat)
|
Loading…
x
Reference in New Issue
Block a user