From a3784fba1e9906a91f285ddcbffdc4a76696b67b Mon Sep 17 00:00:00 2001 From: Tobias Schmitz Date: Wed, 9 Jul 2025 16:32:41 +0200 Subject: test: add test cases Some of the stroked rectangles are still undesirable, but they are still added as a reference. --- ...rect-small-radius-and-stroke-cap-variations.png | Bin 0 -> 4031 bytes ...ations-with-radius-and-adjacent-thin-stroke.png | Bin 0 -> 8121 bytes ...-with-radius-and-adjacent-zero-width-stroke.png | Bin 0 -> 6552 bytes tests/ref/rect-stroke-variations-with-radius.png | Bin 0 -> 6342 bytes .../ref/rect-stroke-variations-without-radius.png | Bin 0 -> 5051 bytes tests/suite/visualize/rect.typ | 238 +++++++++++++++++++++ 6 files changed, 238 insertions(+) create mode 100644 tests/ref/rect-small-radius-and-stroke-cap-variations.png create mode 100644 tests/ref/rect-stroke-variations-with-radius-and-adjacent-thin-stroke.png create mode 100644 tests/ref/rect-stroke-variations-with-radius-and-adjacent-zero-width-stroke.png create mode 100644 tests/ref/rect-stroke-variations-with-radius.png create mode 100644 tests/ref/rect-stroke-variations-without-radius.png diff --git a/tests/ref/rect-small-radius-and-stroke-cap-variations.png b/tests/ref/rect-small-radius-and-stroke-cap-variations.png new file mode 100644 index 00000000..d82a92f4 Binary files /dev/null and b/tests/ref/rect-small-radius-and-stroke-cap-variations.png differ diff --git a/tests/ref/rect-stroke-variations-with-radius-and-adjacent-thin-stroke.png b/tests/ref/rect-stroke-variations-with-radius-and-adjacent-thin-stroke.png new file mode 100644 index 00000000..a4bd33db Binary files /dev/null and b/tests/ref/rect-stroke-variations-with-radius-and-adjacent-thin-stroke.png differ diff --git a/tests/ref/rect-stroke-variations-with-radius-and-adjacent-zero-width-stroke.png b/tests/ref/rect-stroke-variations-with-radius-and-adjacent-zero-width-stroke.png new file mode 100644 index 00000000..469f9369 Binary files /dev/null and b/tests/ref/rect-stroke-variations-with-radius-and-adjacent-zero-width-stroke.png differ diff --git a/tests/ref/rect-stroke-variations-with-radius.png b/tests/ref/rect-stroke-variations-with-radius.png new file mode 100644 index 00000000..fa73c86f Binary files /dev/null and b/tests/ref/rect-stroke-variations-with-radius.png differ diff --git a/tests/ref/rect-stroke-variations-without-radius.png b/tests/ref/rect-stroke-variations-without-radius.png new file mode 100644 index 00000000..8771df1d Binary files /dev/null and b/tests/ref/rect-stroke-variations-without-radius.png differ diff --git a/tests/suite/visualize/rect.typ b/tests/suite/visualize/rect.typ index ba5792b7..9a510f53 100644 --- a/tests/suite/visualize/rect.typ +++ b/tests/suite/visualize/rect.typ @@ -127,3 +127,241 @@ #rect() #rect(height: 60pt) #rect(width: 60pt) + +--- rect-stroke-variations-without-radius --- +#set page(width: 12cm) +#let bg-rect(inner) = { + rect(inset: 0pt, outset: 0pt, fill: luma(200), inner) +} +#let test-block(cap: "butt", dash: none, adjacent: none, radius: 0pt) = { + let adjacent-stroke = if adjacent == none { + none + } else { + (thickness: adjacent, paint: red, dash: dash) + } + bg-rect( + block( + height: 4em, + width: 5em, + stroke: ( + top: adjacent-stroke, + right: (cap: cap, thickness: 6pt, dash: dash, paint: green.transparentize(40%)), + bottom: (cap: cap, thickness: 2pt, dash: dash, paint: blue.transparentize(40%)), + left: adjacent-stroke + ), + radius: radius, + ) + ) +} +#table( + columns: 4 * (1fr,), + [], [butt], [square], [round], + [no dash], + test-block(cap: "butt"), + test-block(cap: "square"), + test-block(cap: "round"), + + [dashed], + test-block(cap: "butt", dash: "dashed"), + test-block(cap: "square", dash: "dashed"), + test-block(cap: "round", dash: "dashed"), + + [loosely-dashed], + test-block(cap: "butt", dash: "loosely-dashed"), + test-block(cap: "square", dash: "loosely-dashed"), + test-block(cap: "round", dash: "loosely-dashed"), +) + +--- rect-stroke-variations-with-radius --- +#set page(width: 12cm) +#let bg-rect(inner) = { + rect(inset: 0pt, outset: 0pt, fill: luma(200), inner) +} +#let test-block(cap: "butt", dash: none, adjacent: none, radius: 0pt) = { + let adjacent-stroke = if adjacent == none { + none + } else { + (thickness: adjacent, paint: red, dash: dash) + } + bg-rect( + block( + height: 4em, + width: 5em, + stroke: ( + top: adjacent-stroke, + right: (cap: cap, thickness: 6pt, dash: dash, paint: green.transparentize(40%)), + bottom: (cap: cap, thickness: 2pt, dash: dash, paint: blue.transparentize(40%)), + left: adjacent-stroke + ), + radius: radius, + ) + ) +} +#table( + columns: 4 * (1fr,), + [], [butt], [square], [round], + [no dash], + test-block(cap: "butt", radius: 12pt), + test-block(cap: "square", radius: 12pt), + test-block(cap: "round", radius: 12pt), + + [dashed], + test-block(cap: "butt", radius: 12pt, dash: "dashed"), + test-block(cap: "square", radius: 12pt, dash: "dashed"), + test-block(cap: "round", radius: 12pt, dash: "dashed"), + + [loosely-dashed], + test-block(cap: "butt", radius: 12pt, dash: "loosely-dashed"), + test-block(cap: "square", radius: 12pt, dash: "loosely-dashed"), + test-block(cap: "round", radius: 12pt, dash: "loosely-dashed"), +) + +--- rect-stroke-variations-with-radius-and-adjacent-zero-width-stroke --- +#set page(width: 12cm) +#let bg-rect(inner) = { + rect(inset: 0pt, outset: 0pt, fill: luma(200), inner) +} +#let test-block(cap: "butt", dash: none, adjacent: none, radius: 0pt) = { + let adjacent-stroke = if adjacent == none { + none + } else { + (thickness: adjacent, paint: red, dash: dash) + } + bg-rect( + block( + height: 4em, + width: 5em, + stroke: ( + top: adjacent-stroke, + right: (cap: cap, thickness: 6pt, dash: dash, paint: green.transparentize(40%)), + bottom: (cap: cap, thickness: 2pt, dash: dash, paint: blue.transparentize(40%)), + left: adjacent-stroke + ), + radius: radius, + ) + ) +} +#table( + columns: 4 * (1fr,), + [], [butt], [square], [round], + [no dash], + test-block(cap: "butt", radius: 12pt, adjacent: 0pt), + test-block(cap: "square", radius: 12pt, adjacent: 0pt), + test-block(cap: "round", radius: 12pt, adjacent: 0pt), + + [dashed], + test-block(cap: "butt", radius: 12pt, adjacent: 0pt, dash: "dashed"), + test-block(cap: "square", radius: 12pt, adjacent: 0pt, dash: "dashed"), + test-block(cap: "round", radius: 12pt, adjacent: 0pt, dash: "dashed"), + + [loosely-dashed], + test-block(cap: "butt", radius: 12pt, adjacent: 0pt, dash: "loosely-dashed"), + test-block(cap: "square", radius: 12pt, adjacent: 0pt, dash: "loosely-dashed"), + test-block(cap: "round", radius: 12pt, adjacent: 0pt, dash: "loosely-dashed"), +) + +--- rect-stroke-variations-with-radius-and-adjacent-thin-stroke --- +#set page(width: 12cm) +#let bg-rect(inner) = { + rect(inset: 0pt, outset: 0pt, fill: luma(200), inner) +} +#let test-block(cap: "butt", dash: none, adjacent: none, radius: 0pt) = { + let adjacent-stroke = if adjacent == none { + none + } else { + (thickness: adjacent, paint: red, dash: dash) + } + bg-rect( + block( + height: 4em, + width: 5em, + stroke: ( + top: adjacent-stroke, + right: (cap: cap, thickness: 6pt, dash: dash, paint: green.transparentize(40%)), + bottom: (cap: cap, thickness: 2pt, dash: dash, paint: blue.transparentize(40%)), + left: adjacent-stroke + ), + radius: radius, + ) + ) +} +#table( + columns: 4 * (1fr,), + [], [butt], [square], [round], + [no dash], + test-block(cap: "butt", radius: 12pt, adjacent: 1pt), + test-block(cap: "square", radius: 12pt, adjacent: 1pt), + test-block(cap: "round", radius: 12pt, adjacent: 1pt), + + [dashed], + test-block(cap: "butt", radius: 12pt, adjacent: 1pt, dash: "dashed"), + test-block(cap: "square", radius: 12pt, adjacent: 1pt, dash: "dashed"), + test-block(cap: "round", radius: 12pt, adjacent: 1pt, dash: "dashed"), + + [loosely-dashed], + test-block(cap: "butt", radius: 12pt, adjacent: 1pt, dash: "loosely-dashed"), + test-block(cap: "square", radius: 12pt, adjacent: 1pt, dash: "loosely-dashed"), + test-block(cap: "round", radius: 12pt, adjacent: 1pt, dash: "loosely-dashed"), +) + +--- rect-small-radius-and-stroke-cap-variations --- +#set page(width: 12cm) +#let bg-rect(inner) = { + rect(inset: 0pt, outset: 0pt, fill: luma(200), inner) +} +#let another-block(cap: "butt", radius: 5pt, adjacent: none) = { + let adjacent-stroke = if adjacent != none { + adjacent + } else { + none + } + bg-rect( + block( + height: 4em, + width: 5em, + stroke: ( + top: adjacent-stroke, + right: (cap: cap, thickness: 5pt), + bottom: (cap: cap, thickness: 5pt), + left: adjacent-stroke, + ), + radius: radius, + ) + ) +} + +#table( + columns: 4 * (1fr,), + [], [none], [0 width], [thin], + [], table.cell(colspan: 3)[radius same as thickness], + [butt], + another-block(cap: "butt", adjacent: none), + another-block(cap: "butt", adjacent: 0pt), + another-block(cap: "butt", adjacent: 1pt), + + [square], + another-block(cap: "square", adjacent: none), + another-block(cap: "square", adjacent: 0pt), + another-block(cap: "square", adjacent: 1pt), + + [round], + another-block(cap: "round", adjacent: none), + another-block(cap: "round", adjacent: 0pt), + another-block(cap: "round", adjacent: 1pt), + + [], table.cell(colspan: 3)[radius smaller than thickness], + [butt], + another-block(cap: "butt", radius: 2pt, adjacent: none), + another-block(cap: "butt", radius: 2pt, adjacent: 0pt), + another-block(cap: "butt", radius: 2pt, adjacent: 1pt), + + [square], + another-block(cap: "square", radius: 2pt, adjacent: none), + another-block(cap: "square", radius: 2pt, adjacent: 0pt), + another-block(cap: "square", radius: 2pt, adjacent: 1pt), + + [round], + another-block(cap: "round", radius: 2pt, adjacent: none), + another-block(cap: "round", radius: 2pt, adjacent: 0pt), + another-block(cap: "round", radius: 2pt, adjacent: 1pt), +) -- cgit v1.2.3