From e10b3d838a75ea351f8477e07f2e1e647f4539dc Mon Sep 17 00:00:00 2001 From: Laurenz Date: Mon, 27 Sep 2021 13:40:56 +0200 Subject: Fix panic due to bad alignments in stack function --- tests/ref/layout/stack.png | Bin 325 -> 318 bytes tests/typ/layout/stack.typ | 34 ++++++++++++++++++++++++---------- 2 files changed, 24 insertions(+), 10 deletions(-) (limited to 'tests') diff --git a/tests/ref/layout/stack.png b/tests/ref/layout/stack.png index 2f190c4d..bc0eb48b 100644 Binary files a/tests/ref/layout/stack.png and b/tests/ref/layout/stack.png differ diff --git a/tests/typ/layout/stack.typ b/tests/typ/layout/stack.typ index 729d85fc..384f574f 100644 --- a/tests/typ/layout/stack.typ +++ b/tests/typ/layout/stack.typ @@ -1,18 +1,32 @@ // Test stack layouts. --- -#let rect(width, fill) = rect(width: width, height: 1cm, fill: fill) -#stack( - rect(2cm, rgb("2a631a")), - rect(3cm, forest), - rect(1cm, conifer), +// Test stacks with different directions. +#let widths = ( + 30pt, 20pt, 40pt, 15pt, + 30pt, 50%, 20pt, 100%, ) +#let shaded = { + let v = 0 + let next() = { v += 0.1; rgb(v, v, v) } + w => rect(width: w, height: 10pt, fill: next()) +} + +#let items = for w in widths { (shaded(w),) } + +#align(right) +#page(width: 50pt, margins: 0pt) +#stack(dir: btt, ..items) +#pagebreak() + +// Currently stack works like flexbox apparently. +#stack(dir: ltr, ..items) + --- // Test overflowing stack. - -#let rect(width, fill) = rect(width: 1cm, height: 0.4cm, fill: fill) -#box(height: 0.5cm, stack( - rect(3cm, forest), - rect(1cm, conifer), +#page(width: 50pt, height: 30pt, margins: 0pt) +#box(stack( + rect(width: 40pt, height: 20pt, fill: conifer), + rect(width: 30pt, height: 13pt, fill: forest), )) -- cgit v1.2.3