summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorLaurenz <laurmaedje@gmail.com>2022-05-03 23:56:57 +0200
committerGitHub <noreply@github.com>2022-05-03 23:56:57 +0200
commitaa10ea8470763afe98d5ff558381f0a0beb0c017 (patch)
tree938f58a8e0faa4f5216920fc3e82d86301d2f094 /tests
parentf9e115daf54c29358f890b137f50a33a781af680 (diff)
parent51d0de09c6f7e2af4db3b65c3fe9595c501b82c9 (diff)
Merge pull request #69 from typst/shapeees
Advanced shapes
Diffstat (limited to 'tests')
-rw-r--r--tests/ref/graphics/shape-ellipse.pngbin22046 -> 24571 bytes
-rw-r--r--tests/ref/graphics/shape-fill-stroke.pngbin2997 -> 6371 bytes
-rw-r--r--tests/ref/graphics/shape-rect.pngbin7261 -> 13791 bytes
-rw-r--r--tests/typ/code/let.typ2
-rw-r--r--tests/typ/code/target.typ2
-rw-r--r--tests/typ/graphics/shape-aspect.typ2
-rw-r--r--tests/typ/graphics/shape-circle.typ4
-rw-r--r--tests/typ/graphics/shape-ellipse.typ5
-rw-r--r--tests/typ/graphics/shape-fill-stroke.typ10
-rw-r--r--tests/typ/graphics/shape-rect.typ31
-rw-r--r--tests/typ/graphics/shape-square.typ2
-rw-r--r--tests/typ/layout/columns.typ6
-rw-r--r--tests/typ/layout/page-margin.typ10
-rw-r--r--tests/typ/layout/page-marginals.typ5
-rw-r--r--tests/typ/layout/page.typ2
-rw-r--r--tests/typ/style/construct.typ6
-rw-r--r--tests/typeset.rs10
17 files changed, 68 insertions, 29 deletions
diff --git a/tests/ref/graphics/shape-ellipse.png b/tests/ref/graphics/shape-ellipse.png
index 740f005f..296fc14e 100644
--- a/tests/ref/graphics/shape-ellipse.png
+++ b/tests/ref/graphics/shape-ellipse.png
Binary files differ
diff --git a/tests/ref/graphics/shape-fill-stroke.png b/tests/ref/graphics/shape-fill-stroke.png
index f2278c88..91cddcc2 100644
--- a/tests/ref/graphics/shape-fill-stroke.png
+++ b/tests/ref/graphics/shape-fill-stroke.png
Binary files differ
diff --git a/tests/ref/graphics/shape-rect.png b/tests/ref/graphics/shape-rect.png
index 1fdb0dac..5bbaf3db 100644
--- a/tests/ref/graphics/shape-rect.png
+++ b/tests/ref/graphics/shape-rect.png
Binary files differ
diff --git a/tests/typ/code/let.typ b/tests/typ/code/let.typ
index a95d651a..c3be64a5 100644
--- a/tests/typ/code/let.typ
+++ b/tests/typ/code/let.typ
@@ -11,7 +11,7 @@
// Syntax sugar for function definitions.
#let fill = conifer
-#let rect(body) = rect(width: 2cm, fill: fill, padding: 5pt, body)
+#let rect(body) = rect(width: 2cm, fill: fill, inset: 5pt, body)
#rect[Hi!]
---
diff --git a/tests/typ/code/target.typ b/tests/typ/code/target.typ
index 6c321592..b0a3fbf3 100644
--- a/tests/typ/code/target.typ
+++ b/tests/typ/code/target.typ
@@ -7,6 +7,6 @@
#let d = 3
#let value = [hi]
#let item(a, b) = a + b
-#let fn = rect.with(fill: conifer, padding: 5pt)
+#let fn = rect.with(fill: conifer, inset: 5pt)
Some _includable_ text.
diff --git a/tests/typ/graphics/shape-aspect.typ b/tests/typ/graphics/shape-aspect.typ
index 970857b6..70d689f7 100644
--- a/tests/typ/graphics/shape-aspect.typ
+++ b/tests/typ/graphics/shape-aspect.typ
@@ -11,7 +11,7 @@
---
// Test alignment in automatically sized square and circle.
#set text(8pt)
-#square(padding: 4pt)[
+#square(inset: 4pt)[
Hey there, #align(center + bottom, rotate(180deg, [you!]))
]
#circle(align(center + horizon, [Hey.]))
diff --git a/tests/typ/graphics/shape-circle.typ b/tests/typ/graphics/shape-circle.typ
index dc1e3f24..13ff67de 100644
--- a/tests/typ/graphics/shape-circle.typ
+++ b/tests/typ/graphics/shape-circle.typ
@@ -16,13 +16,13 @@ Auto-sized circle. \
Center-aligned rect in auto-sized circle.
#circle(fill: forest, stroke: conifer,
align(center + horizon,
- rect(fill: conifer, padding: 5pt)[But, soft!]
+ rect(fill: conifer, inset: 5pt)[But, soft!]
)
)
Rect in auto-sized circle. \
#circle(fill: forest,
- rect(fill: conifer, stroke: white, padding: 4pt)[
+ rect(fill: conifer, stroke: white, inset: 4pt)[
#set text(8pt)
But, soft! what light through yonder window breaks?
]
diff --git a/tests/typ/graphics/shape-ellipse.typ b/tests/typ/graphics/shape-ellipse.typ
index 995eabb9..ba4d0d0a 100644
--- a/tests/typ/graphics/shape-ellipse.typ
+++ b/tests/typ/graphics/shape-ellipse.typ
@@ -17,7 +17,10 @@ Rect in ellipse in fixed rect. \
)
Auto-sized ellipse. \
-#ellipse(fill: conifer, stroke: 3pt + forest, padding: 3pt)[
+#ellipse(fill: conifer, stroke: 3pt + forest, inset: 3pt)[
#set text(8pt)
But, soft! what light through yonder window breaks?
]
+
+
+An inline #ellipse(width: 8pt, height: 6pt, outset: (top: 3pt, rest: 5.5pt)) ellipse. \ No newline at end of file
diff --git a/tests/typ/graphics/shape-fill-stroke.typ b/tests/typ/graphics/shape-fill-stroke.typ
index c09cb065..d14d0981 100644
--- a/tests/typ/graphics/shape-fill-stroke.typ
+++ b/tests/typ/graphics/shape-fill-stroke.typ
@@ -38,3 +38,13 @@
#sq(stroke: blue)
#sq(fill: teal, stroke: blue)
#sq(fill: teal, stroke: 2pt + blue)
+
+---
+// Test stroke composition.
+#set square(stroke: 4pt)
+#set text("Roboto")
+#square(
+ stroke: (left: red, top: yellow, right: green, bottom: blue),
+ radius: 100%, align(center+horizon)[*G*],
+ inset: 8pt
+)
diff --git a/tests/typ/graphics/shape-rect.typ b/tests/typ/graphics/shape-rect.typ
index e035fc91..a29550b5 100644
--- a/tests/typ/graphics/shape-rect.typ
+++ b/tests/typ/graphics/shape-rect.typ
@@ -8,7 +8,7 @@
#set page(width: 150pt)
// Fit to text.
-#rect(fill: conifer, padding: 3pt)[Textbox]
+#rect(fill: conifer, inset: 3pt)[Textbox]
// Empty with fixed width and height.
#block(rect(
@@ -18,7 +18,7 @@
))
// Fixed width, text height.
-#rect(width: 2cm, fill: rgb("9650d6"), padding: 5pt)[Fixed and padded]
+#rect(width: 2cm, fill: rgb("9650d6"), inset: 5pt)[Fixed and padded]
// Page width, fixed height.
#rect(height: 1cm, width: 100%, fill: rgb("734ced"))[Topleft]
@@ -27,3 +27,30 @@
\{#rect(width: 0.5in, height: 7pt, fill: rgb("d6cd67"))
#rect(width: 0.5in, height: 7pt, fill: rgb("edd466"))
#rect(width: 0.5in, height: 7pt, fill: rgb("e3be62"))\}
+
+// Rounded corners.
+#rect(width: 2cm, radius: 60%)
+#rect(width: 1cm, radius: (x: 5pt, y: 10pt))
+#rect(width: 1.25cm, radius: (left: 2pt, top: 5pt, right: 8pt, bottom: 11pt))
+
+// Different strokes.
+[
+ #set rect(stroke: (right: red))
+ #rect(width: 100%, fill: lime, stroke: (x: 5pt, y: 1pt))
+]
+
+---
+// Outset padding.
+#show node: raw as [
+ #set text("IBM Plex Mono", 8pt)
+ #h(.7em, weak: true)
+ #rect(radius: 3pt, outset: (y: 3pt, x: 2.5pt), fill: rgb(239, 241, 243))[{node.text}]
+ #h(.7em, weak: true)
+]
+
+Use the `*const ptr` pointer.
+
+---
+// Error: 15-38 unexpected key "cake"
+#rect(radius: (left: 10pt, cake: 5pt))
+
diff --git a/tests/typ/graphics/shape-square.typ b/tests/typ/graphics/shape-square.typ
index c4ece778..622fa9c8 100644
--- a/tests/typ/graphics/shape-square.typ
+++ b/tests/typ/graphics/shape-square.typ
@@ -7,7 +7,7 @@
---
// Test auto-sized square.
-#square(fill: eastern, padding: 5pt)[
+#square(fill: eastern, inset: 5pt)[
#set text(fill: white, weight: "bold")
Typst
]
diff --git a/tests/typ/layout/columns.typ b/tests/typ/layout/columns.typ
index ce291fb2..1e77e6bc 100644
--- a/tests/typ/layout/columns.typ
+++ b/tests/typ/layout/columns.typ
@@ -16,7 +16,7 @@
// Test the `columns` function.
#set page(width: auto)
-#rect(width: 180pt, height: 100pt, padding: 8pt, columns(2, [
+#rect(width: 180pt, height: 100pt, inset: 8pt, columns(2, [
A special plight has befallen our document.
Columns in text boxes reigned down unto the soil
to waste a year's crop of rich layouts.
@@ -40,7 +40,7 @@ a page for a test but it does get the job done.
// Test the expansion behavior.
#set page(height: 2.5cm, width: 7.05cm)
-#rect(padding: 6pt, columns(2, [
+#rect(inset: 6pt, columns(2, [
ABC \
BCD
#colbreak()
@@ -73,7 +73,7 @@ D
// Test an empty second column.
#set page(width: 7.05cm, columns: 2)
-#rect(width: 100%, padding: 3pt)[So there isn't anything in the second column?]
+#rect(width: 100%, inset: 3pt)[So there isn't anything in the second column?]
---
// Test columns when one of them is empty.
diff --git a/tests/typ/layout/page-margin.typ b/tests/typ/layout/page-margin.typ
index 44126d2d..290c4081 100644
--- a/tests/typ/layout/page-margin.typ
+++ b/tests/typ/layout/page-margin.typ
@@ -11,10 +11,10 @@
---
// Set individual margins.
#set page(height: 40pt)
-[#set page(left: 0pt); #align(left)[Left]]
-[#set page(right: 0pt); #align(right)[Right]]
-[#set page(top: 0pt); #align(top)[Top]]
-[#set page(bottom: 0pt); #align(bottom)[Bottom]]
+[#set page(margins: (left: 0pt)); #align(left)[Left]]
+[#set page(margins: (right: 0pt)); #align(right)[Right]]
+[#set page(margins: (top: 0pt)); #align(top)[Top]]
+[#set page(margins: (bottom: 0pt)); #align(bottom)[Bottom]]
// Ensure that specific margins override general margins.
-[#set page(margins: 0pt, left: 20pt); Overriden]
+[#set page(margins: (rest: 0pt, left: 20pt)); Overriden]
diff --git a/tests/typ/layout/page-marginals.typ b/tests/typ/layout/page-marginals.typ
index 9fd193c6..6e8e3d85 100644
--- a/tests/typ/layout/page-marginals.typ
+++ b/tests/typ/layout/page-marginals.typ
@@ -1,7 +1,6 @@
#set page(
paper: "a8",
- margins: 30pt,
- horizontal: 15pt,
+ margins: (x: 15pt, y: 30pt),
header: align(horizon, {
text(eastern)[*Typst*]
h(1fr)
@@ -18,5 +17,5 @@ do wear it; cast it off. It is my lady, O, it is my love! O, that she knew she
were! She speaks yet she says nothing: what of that? Her eye discourses; I will
answer it.
-#set page(header: none, height: auto, top: 15pt, bottom: 25pt)
+#set page(header: none, height: auto, margins: (top: 15pt, bottom: 25pt))
The END.
diff --git a/tests/typ/layout/page.typ b/tests/typ/layout/page.typ
index 89d0f2fb..3157ebf9 100644
--- a/tests/typ/layout/page.typ
+++ b/tests/typ/layout/page.typ
@@ -24,7 +24,7 @@
// Test page fill.
#set page(width: 80pt, height: 40pt, fill: eastern)
#text(15pt, "Roboto", fill: white, smallcaps: true)[Typst]
-#page(width: 40pt, fill: none, margins: auto, top: 10pt)[Hi]
+#page(width: 40pt, fill: none, margins: (top: 10pt, rest: auto))[Hi]
---
// Just page followed by pagebreak.
diff --git a/tests/typ/style/construct.typ b/tests/typ/style/construct.typ
index f01b534b..890c4b94 100644
--- a/tests/typ/style/construct.typ
+++ b/tests/typ/style/construct.typ
@@ -16,17 +16,17 @@
// but the B should be center-aligned.
#set par(align: center)
#par(align: right)[
- A #rect(width: 2cm, fill: conifer, padding: 4pt)[B]
+ A #rect(width: 2cm, fill: conifer, inset: 4pt)[B]
]
---
// The inner rectangle should also be yellow here.
// (and therefore invisible)
-[#set rect(fill: yellow);#text(1em, rect(padding: 5pt, rect()))]
+[#set rect(fill: yellow);#text(1em, rect(inset: 5pt, rect()))]
---
// The inner rectangle should not be yellow here.
-A #rect(fill: yellow, padding: 5pt, rect()) B
+A #rect(fill: yellow, inset: 5pt, rect()) B
---
// The inner list should not be indented extra.
diff --git a/tests/typeset.rs b/tests/typeset.rs
index 9f84a733..b0452163 100644
--- a/tests/typeset.rs
+++ b/tests/typeset.rs
@@ -12,7 +12,7 @@ use walkdir::WalkDir;
use typst::diag::Error;
use typst::eval::{Smart, Value};
use typst::frame::{Element, Frame};
-use typst::geom::{Length, RgbaColor};
+use typst::geom::{Length, RgbaColor, Sides};
use typst::library::layout::PageNode;
use typst::library::text::{TextNode, TextSize};
use typst::loading::FsLoader;
@@ -64,10 +64,10 @@ fn main() {
let mut styles = StyleMap::new();
styles.set(PageNode::WIDTH, Smart::Custom(Length::pt(120.0).into()));
styles.set(PageNode::HEIGHT, Smart::Auto);
- styles.set(PageNode::LEFT, Smart::Custom(Length::pt(10.0).into()));
- styles.set(PageNode::TOP, Smart::Custom(Length::pt(10.0).into()));
- styles.set(PageNode::RIGHT, Smart::Custom(Length::pt(10.0).into()));
- styles.set(PageNode::BOTTOM, Smart::Custom(Length::pt(10.0).into()));
+ styles.set(
+ PageNode::MARGINS,
+ Sides::splat(Some(Smart::Custom(Length::pt(10.0).into()))),
+ );
styles.set(TextNode::SIZE, TextSize(Length::pt(10.0).into()));
// Hook up an assert function into the global scope.