feat: initial commit
This commit is contained in:
commit
94a6a1d744
454 files changed
+52433
No files matched your search
@@ -0,0 +1,69 @@
|
||||
# Circle
|
||||
|
||||
# circle
|
||||
|
||||
A circle with optional content.
|
||||
|
||||
## Example
|
||||
|
||||
```typst
|
||||
// Without content.
|
||||
#circle(radius: 25pt)
|
||||
|
||||
// With content.
|
||||
#circle[
|
||||
#set align(center + horizon)
|
||||
Automatically \
|
||||
sized to fit.
|
||||
]
|
||||
```
|
||||
|
||||
```typst
|
||||
#circle(
|
||||
radius: length,
|
||||
width: auto | relative,
|
||||
height: auto | relative | fraction,
|
||||
fill: none | color | gradient | tiling,
|
||||
stroke: none | auto | length | color | gradient | stroke | tiling | dictionary,
|
||||
inset: relative | dictionary,
|
||||
outset: relative | dictionary,
|
||||
body
|
||||
) -> content
|
||||
```
|
||||
|
||||
## Parameters
|
||||
|
||||
- radius:
|
||||
- description: The circle\'s radius. This is mutually exclusive with `width` and `height`.
|
||||
- type: length
|
||||
- default: 0pt
|
||||
- width:
|
||||
- description: The circle\'s width. This is mutually exclusive with `radius` and `height`. In contrast to `radius`, this can be relative to the parent container\'s width.
|
||||
- type: auto | relative
|
||||
- default: auto
|
||||
- height:
|
||||
- description: The circle\'s height. This is mutually exclusive with `radius` and `width`. In contrast to `radius`, this can be relative to the parent container\'s height.
|
||||
- type: auto | relative | fraction
|
||||
- default: auto
|
||||
- fill:
|
||||
- description: How to fill the circle. See the [rectangle\'s documentation](/docs/reference/visualize/rect/#parameters-fill) for more details.
|
||||
- type: none | color | gradient | tiling
|
||||
- default: none
|
||||
- stroke:
|
||||
- description: How to stroke the circle. See the [rectangle\'s documentation](/docs/reference/visualize/rect/#parameters-stroke) for more details.
|
||||
- type: none | auto | length | color | gradient | stroke | tiling | dictionary
|
||||
- default: auto
|
||||
- inset:
|
||||
- description: How much to pad the circle\'s content. See the [box\'s documentation](/docs/reference/layout/box/#parameters-inset) for more details.
|
||||
- type: relative | dictionary
|
||||
- default: 0 % + 5pt
|
||||
- outset:
|
||||
- description: How much to expand the circle\'s size without affecting the layout. See the [box\'s documentation](/docs/reference/layout/box/#parameters-outset) for more details.
|
||||
- type: relative | dictionary
|
||||
- default: (:)
|
||||
- body:
|
||||
- description: The content to place into the circle. The circle expands to fit this content, keeping the 1-1 aspect ratio.
|
||||
- type: none | content
|
||||
- default: none
|
||||
|
||||
|
||||
@@ -0,0 +1,766 @@
|
||||
# Color
|
||||
|
||||
A color in a specific color space.
|
||||
|
||||
Typst supports:
|
||||
|
||||
- sRGB through the [`rgb` function](/docs/reference/visualize/color/#definitions-rgb)
|
||||
- Device CMYK through the [`cmyk` function](/docs/reference/visualize/color/#definitions-cmyk)
|
||||
- D65 Gray through the [`luma` function](/docs/reference/visualize/color/#definitions-luma)
|
||||
- Oklab through the [`oklab` function](/docs/reference/visualize/color/#definitions-oklab)
|
||||
- Oklch through the [`oklch` function](/docs/reference/visualize/color/#definitions-oklch)
|
||||
- Linear RGB through the [`color.linear-rgb` function](/docs/reference/visualize/color/#definitions-linear-rgb)
|
||||
- HSL through the [`color.hsl` function](/docs/reference/visualize/color/#definitions-hsl)
|
||||
- HSV through the [`color.hsv` function](/docs/reference/visualize/color/#definitions-hsv)
|
||||
|
||||
## Example
|
||||
|
||||
```typst
|
||||
#rect(fill: aqua)
|
||||
```
|
||||
|
||||
## Predefined colors
|
||||
|
||||
Typst defines the following built-in colors:
|
||||
|
||||
| Color | Definition |
|
||||
| --- | --- |
|
||||
| `black` | `luma(0)` |
|
||||
| `gray` | `luma(170)` |
|
||||
| `silver` | `luma(221)` |
|
||||
| `white` | `luma(255)` |
|
||||
| `navy` | `rgb("#001f3f")` |
|
||||
| `blue` | `rgb("#0074d9")` |
|
||||
| `aqua` | `rgb("#7fdbff")` |
|
||||
| `teal` | `rgb("#39cccc")` |
|
||||
| `eastern` | `rgb("#239dad")` |
|
||||
| `purple` | `rgb("#b10dc9")` |
|
||||
| `fuchsia` | `rgb("#f012be")` |
|
||||
| `maroon` | `rgb("#85144b")` |
|
||||
| `red` | `rgb("#ff4136")` |
|
||||
| `orange` | `rgb("#ff851b")` |
|
||||
| `yellow` | `rgb("#ffdc00")` |
|
||||
| `olive` | `rgb("#3d9970")` |
|
||||
| `green` | `rgb("#2ecc40")` |
|
||||
| `lime` | `rgb("#01ff70")` |
|
||||
|
||||
The predefined colors and the most important color constructors are available globally and also in the color type's scope, so you can write either `color.red` or just `red`.
|
||||
|
||||
## Predefined color maps
|
||||
|
||||
Typst also includes a number of preset color maps that can be used for [gradients](/docs/reference/visualize/gradient/#stops). These are simply arrays of colors defined in the module `color.map`.
|
||||
|
||||
```typst
|
||||
#circle(fill: gradient.linear(..color.map.crest))
|
||||
```
|
||||
|
||||
| Map | Details |
|
||||
| --- | --- |
|
||||
| `turbo` | A perceptually uniform rainbow-like color map. Read [this blog post](https://ai.googleblog.com/2019/08/turbo-improved-rainbow-colormap-for.html) for more details. |
|
||||
| `cividis` | A blue to gray to yellow color map. See [this blog post](https://bids.github.io/colormap/) for more details. |
|
||||
| `rainbow` | Cycles through the full color spectrum. This color map is best used by setting the interpolation color space to [HSL](/docs/reference/visualize/color/#definitions-hsl). The rainbow gradient is **not suitable** for data visualization because it is not perceptually uniform, so the differences between values become unclear to your readers. It should only be used for decorative purposes. |
|
||||
| `spectral` | Red to yellow to blue color map. |
|
||||
| `viridis` | A purple to teal to yellow color map. |
|
||||
| `inferno` | A black to red to yellow color map. |
|
||||
| `magma` | A black to purple to yellow color map. |
|
||||
| `plasma` | A purple to pink to yellow color map. |
|
||||
| `rocket` | A black to red to white color map. |
|
||||
| `mako` | A black to teal to white color map. |
|
||||
| `vlag` | A light blue to white to red color map. |
|
||||
| `icefire` | A light teal to black to orange color map. |
|
||||
| `flare` | A orange to purple color map that is perceptually uniform. |
|
||||
| `crest` | A light green to blue color map. |
|
||||
|
||||
Some popular presets are not included because they are not available under a free licence. Others, like [Jet](https://jakevdp.github.io/blog/2014/10/16/how-bad-is-your-colormap/), are not included because they are not color blind friendly. Feel free to use or create a package with other presets that are useful to you!
|
||||
|
||||
|
||||
## Methods
|
||||
|
||||
## color.luma
|
||||
|
||||
Create a grayscale color.
|
||||
|
||||
A grayscale color is represented internally by a single `lightness` component.
|
||||
|
||||
These components are also available using the [`components`](/docs/reference/visualize/color/#definitions-components) method.
|
||||
|
||||
```typst
|
||||
#for x in range(250, step: 50) {
|
||||
box(square(fill: luma(x)))
|
||||
}
|
||||
```
|
||||
|
||||
```typst
|
||||
#color.luma(
|
||||
lightness,
|
||||
alpha,
|
||||
color
|
||||
) -> color
|
||||
```
|
||||
|
||||
### Parameters
|
||||
|
||||
- lightness:
|
||||
- description: The lightness component.
|
||||
- type: int | ratio
|
||||
- default: None
|
||||
- alpha:
|
||||
- description: The alpha component.
|
||||
- type: ratio
|
||||
- default: None
|
||||
- color:
|
||||
- description: Alternatively: The color to convert to grayscale. If this is given, the `lightness` should not be given.
|
||||
- type: color
|
||||
- default: None
|
||||
|
||||
## color.oklab
|
||||
|
||||
Create an [Oklab](https://bottosson.github.io/posts/oklab/) color.
|
||||
|
||||
This color space is well suited for the following use cases:
|
||||
|
||||
- Color manipulation such as saturating while keeping perceived hue
|
||||
- Creating grayscale images with uniform perceived lightness
|
||||
- Creating smooth and uniform color transition and gradients
|
||||
|
||||
A linear Oklab color is represented internally by an array of four components:
|
||||
|
||||
- lightness ([`ratio`](/docs/reference/layout/ratio/))
|
||||
- a ([`float`](/docs/reference/foundations/float/) or [`ratio`](/docs/reference/layout/ratio/). Ratios are relative to `0.4`; meaning `50%` is equal to `0.2`)
|
||||
- b ([`float`](/docs/reference/foundations/float/) or [`ratio`](/docs/reference/layout/ratio/). Ratios are relative to `0.4`; meaning `50%` is equal to `0.2`)
|
||||
- alpha ([`ratio`](/docs/reference/layout/ratio/))
|
||||
|
||||
These components are also available using the [`components`](/docs/reference/visualize/color/#definitions-components) method.
|
||||
|
||||
```typst
|
||||
#square(
|
||||
fill: oklab(27%, 20%, -3%, 50%)
|
||||
)
|
||||
```
|
||||
|
||||
```typst
|
||||
#color.oklab(
|
||||
lightness,
|
||||
a,
|
||||
b,
|
||||
alpha,
|
||||
color
|
||||
) -> color
|
||||
```
|
||||
|
||||
### Parameters
|
||||
|
||||
- lightness:
|
||||
- description: The lightness component.
|
||||
- type: ratio
|
||||
- default: None
|
||||
- a:
|
||||
- description: The a ("green/red") component.
|
||||
- type: float | ratio
|
||||
- default: None
|
||||
- b:
|
||||
- description: The b ("blue/yellow") component.
|
||||
- type: float | ratio
|
||||
- default: None
|
||||
- alpha:
|
||||
- description: The alpha component.
|
||||
- type: ratio
|
||||
- default: None
|
||||
- color:
|
||||
- description: Alternatively: The color to convert to Oklab. If this is given, the individual components should not be given.
|
||||
- type: color
|
||||
- default: None
|
||||
|
||||
## color.oklch
|
||||
|
||||
Create an [Oklch](https://bottosson.github.io/posts/oklab/) color.
|
||||
|
||||
This color space is well suited for the following use cases:
|
||||
|
||||
- Color manipulation involving lightness, chroma, and hue
|
||||
- Creating grayscale images with uniform perceived lightness
|
||||
- Creating smooth and uniform color transition and gradients
|
||||
|
||||
A linear Oklch color is represented internally by an array of four components:
|
||||
|
||||
- lightness ([`ratio`](/docs/reference/layout/ratio/))
|
||||
- chroma ([`float`](/docs/reference/foundations/float/) or [`ratio`](/docs/reference/layout/ratio/). Ratios are relative to `0.4`; meaning `50%` is equal to `0.2`)
|
||||
- hue ([`angle`](/docs/reference/layout/angle/))
|
||||
- alpha ([`ratio`](/docs/reference/layout/ratio/))
|
||||
|
||||
These components are also available using the [`components`](/docs/reference/visualize/color/#definitions-components) method.
|
||||
|
||||
```typst
|
||||
#square(
|
||||
fill: oklch(40%, 0.2, 160deg, 50%)
|
||||
)
|
||||
```
|
||||
|
||||
```typst
|
||||
#color.oklch(
|
||||
lightness,
|
||||
chroma,
|
||||
hue,
|
||||
alpha,
|
||||
color
|
||||
) -> color
|
||||
```
|
||||
|
||||
### Parameters
|
||||
|
||||
- lightness:
|
||||
- description: The lightness component.
|
||||
- type: ratio
|
||||
- default: None
|
||||
- chroma:
|
||||
- description: The chroma component.
|
||||
- type: float | ratio
|
||||
- default: None
|
||||
- hue:
|
||||
- description: The hue component.
|
||||
- type: angle
|
||||
- default: None
|
||||
- alpha:
|
||||
- description: The alpha component.
|
||||
- type: ratio
|
||||
- default: None
|
||||
- color:
|
||||
- description: Alternatively: The color to convert to Oklch. If this is given, the individual components should not be given.
|
||||
- type: color
|
||||
- default: None
|
||||
|
||||
## color.linear-rgb
|
||||
|
||||
Create an RGB(A) color with linear luma.
|
||||
|
||||
This color space is similar to sRGB, but with the distinction that the color component are not gamma corrected. This makes it easier to perform color operations such as blending and interpolation. Although, you should prefer to use the [`oklab` function](/docs/reference/visualize/color/#definitions-oklab) for these.
|
||||
|
||||
A linear RGB(A) color is represented internally by an array of four components:
|
||||
|
||||
- red ([`ratio`](/docs/reference/layout/ratio/))
|
||||
- green ([`ratio`](/docs/reference/layout/ratio/))
|
||||
- blue ([`ratio`](/docs/reference/layout/ratio/))
|
||||
- alpha ([`ratio`](/docs/reference/layout/ratio/))
|
||||
|
||||
These components are also available using the [`components`](/docs/reference/visualize/color/#definitions-components) method.
|
||||
|
||||
```typst
|
||||
#square(fill: color.linear-rgb(
|
||||
30%, 50%, 10%,
|
||||
))
|
||||
```
|
||||
|
||||
```typst
|
||||
#color.linear-rgb(
|
||||
red,
|
||||
green,
|
||||
blue,
|
||||
alpha,
|
||||
color
|
||||
) -> color
|
||||
```
|
||||
|
||||
### Parameters
|
||||
|
||||
- red:
|
||||
- description: The red component.
|
||||
- type: int | ratio
|
||||
- default: None
|
||||
- green:
|
||||
- description: The green component.
|
||||
- type: int | ratio
|
||||
- default: None
|
||||
- blue:
|
||||
- description: The blue component.
|
||||
- type: int | ratio
|
||||
- default: None
|
||||
- alpha:
|
||||
- description: The alpha component.
|
||||
- type: int | ratio
|
||||
- default: None
|
||||
- color:
|
||||
- description: Alternatively: The color to convert to linear RGB(A). If this is given, the individual components should not be given.
|
||||
- type: color
|
||||
- default: None
|
||||
|
||||
## color.rgb
|
||||
|
||||
Create an RGB(A) color.
|
||||
|
||||
The color is specified in the sRGB color space.
|
||||
|
||||
An RGB(A) color is represented internally by an array of four components:
|
||||
|
||||
- red ([`ratio`](/docs/reference/layout/ratio/))
|
||||
- green ([`ratio`](/docs/reference/layout/ratio/))
|
||||
- blue ([`ratio`](/docs/reference/layout/ratio/))
|
||||
- alpha ([`ratio`](/docs/reference/layout/ratio/))
|
||||
|
||||
These components are also available using the [`components`](/docs/reference/visualize/color/#definitions-components) method.
|
||||
|
||||
```typst
|
||||
#square(fill: rgb("#b1f2eb"))
|
||||
#square(fill: rgb(87, 127, 230))
|
||||
#square(fill: rgb(25%, 13%, 65%))
|
||||
```
|
||||
|
||||
```typst
|
||||
#color.rgb(
|
||||
red,
|
||||
green,
|
||||
blue,
|
||||
alpha,
|
||||
hex,
|
||||
color
|
||||
) -> color
|
||||
```
|
||||
|
||||
### Parameters
|
||||
|
||||
- red:
|
||||
- description: The red component.
|
||||
- type: int | ratio
|
||||
- default: None
|
||||
- green:
|
||||
- description: The green component.
|
||||
- type: int | ratio
|
||||
- default: None
|
||||
- blue:
|
||||
- description: The blue component.
|
||||
- type: int | ratio
|
||||
- default: None
|
||||
- alpha:
|
||||
- description: The alpha component.
|
||||
- type: int | ratio
|
||||
- default: None
|
||||
- hex:
|
||||
- description: Alternatively: The color in hexadecimal notation. Accepts three, four, six or eight hexadecimal digits and optionally a leading hash. If this is given, the individual components should not be given. ```typst #text(16pt, rgb("#239dad"))[ *Typst* ] ```
|
||||
- type: str
|
||||
- default: None
|
||||
- color:
|
||||
- description: Alternatively: The color to convert to RGB(a). If this is given, the individual components should not be given.
|
||||
- type: color
|
||||
- default: None
|
||||
|
||||
## color.cmyk
|
||||
|
||||
Create a CMYK color.
|
||||
|
||||
This is useful if you want to target a specific printer. The conversion to RGB for display preview might differ from how your printer reproduces the color.
|
||||
|
||||
A CMYK color is represented internally by an array of four components:
|
||||
|
||||
- cyan ([`ratio`](/docs/reference/layout/ratio/))
|
||||
- magenta ([`ratio`](/docs/reference/layout/ratio/))
|
||||
- yellow ([`ratio`](/docs/reference/layout/ratio/))
|
||||
- key ([`ratio`](/docs/reference/layout/ratio/))
|
||||
|
||||
These components are also available using the [`components`](/docs/reference/visualize/color/#definitions-components) method.
|
||||
|
||||
Note that CMYK colors are not currently supported when PDF/A output is enabled.
|
||||
|
||||
```typst
|
||||
#square(
|
||||
fill: cmyk(27%, 0%, 3%, 5%)
|
||||
)
|
||||
```
|
||||
|
||||
```typst
|
||||
#color.cmyk(
|
||||
cyan,
|
||||
magenta,
|
||||
yellow,
|
||||
key,
|
||||
color
|
||||
) -> color
|
||||
```
|
||||
|
||||
### Parameters
|
||||
|
||||
- cyan:
|
||||
- description: The cyan component.
|
||||
- type: ratio
|
||||
- default: None
|
||||
- magenta:
|
||||
- description: The magenta component.
|
||||
- type: ratio
|
||||
- default: None
|
||||
- yellow:
|
||||
- description: The yellow component.
|
||||
- type: ratio
|
||||
- default: None
|
||||
- key:
|
||||
- description: The key component.
|
||||
- type: ratio
|
||||
- default: None
|
||||
- color:
|
||||
- description: Alternatively: The color to convert to CMYK. If this is given, the individual components should not be given.
|
||||
- type: color
|
||||
- default: None
|
||||
|
||||
## color.hsl
|
||||
|
||||
Create an HSL color.
|
||||
|
||||
This color space is useful for specifying colors by hue, saturation and lightness. It is also useful for color manipulation, such as saturating while keeping perceived hue.
|
||||
|
||||
An HSL color is represented internally by an array of four components:
|
||||
|
||||
- hue ([`angle`](/docs/reference/layout/angle/))
|
||||
- saturation ([`ratio`](/docs/reference/layout/ratio/))
|
||||
- lightness ([`ratio`](/docs/reference/layout/ratio/))
|
||||
- alpha ([`ratio`](/docs/reference/layout/ratio/))
|
||||
|
||||
These components are also available using the [`components`](/docs/reference/visualize/color/#definitions-components) method.
|
||||
|
||||
```typst
|
||||
#square(
|
||||
fill: color.hsl(30deg, 50%, 60%)
|
||||
)
|
||||
```
|
||||
|
||||
```typst
|
||||
#color.hsl(
|
||||
hue,
|
||||
saturation,
|
||||
lightness,
|
||||
alpha,
|
||||
color
|
||||
) -> color
|
||||
```
|
||||
|
||||
### Parameters
|
||||
|
||||
- hue:
|
||||
- description: The hue angle.
|
||||
- type: angle
|
||||
- default: None
|
||||
- saturation:
|
||||
- description: The saturation component.
|
||||
- type: int | ratio
|
||||
- default: None
|
||||
- lightness:
|
||||
- description: The lightness component.
|
||||
- type: int | ratio
|
||||
- default: None
|
||||
- alpha:
|
||||
- description: The alpha component.
|
||||
- type: int | ratio
|
||||
- default: None
|
||||
- color:
|
||||
- description: Alternatively: The color to convert to HSL. If this is given, the individual components should not be given.
|
||||
- type: color
|
||||
- default: None
|
||||
|
||||
## color.hsv
|
||||
|
||||
Create an HSV color.
|
||||
|
||||
This color space is useful for specifying colors by hue, saturation and value. It is also useful for color manipulation, such as saturating while keeping perceived hue.
|
||||
|
||||
An HSV color is represented internally by an array of four components:
|
||||
|
||||
- hue ([`angle`](/docs/reference/layout/angle/))
|
||||
- saturation ([`ratio`](/docs/reference/layout/ratio/))
|
||||
- value ([`ratio`](/docs/reference/layout/ratio/))
|
||||
- alpha ([`ratio`](/docs/reference/layout/ratio/))
|
||||
|
||||
These components are also available using the [`components`](/docs/reference/visualize/color/#definitions-components) method.
|
||||
|
||||
```typst
|
||||
#square(
|
||||
fill: color.hsv(30deg, 50%, 60%)
|
||||
)
|
||||
```
|
||||
|
||||
```typst
|
||||
#color.hsv(
|
||||
hue,
|
||||
saturation,
|
||||
value,
|
||||
alpha,
|
||||
color
|
||||
) -> color
|
||||
```
|
||||
|
||||
### Parameters
|
||||
|
||||
- hue:
|
||||
- description: The hue angle.
|
||||
- type: angle
|
||||
- default: None
|
||||
- saturation:
|
||||
- description: The saturation component.
|
||||
- type: int | ratio
|
||||
- default: None
|
||||
- value:
|
||||
- description: The value component.
|
||||
- type: int | ratio
|
||||
- default: None
|
||||
- alpha:
|
||||
- description: The alpha component.
|
||||
- type: int | ratio
|
||||
- default: None
|
||||
- color:
|
||||
- description: Alternatively: The color to convert to HSL. If this is given, the individual components should not be given.
|
||||
- type: color
|
||||
- default: None
|
||||
|
||||
## color.components
|
||||
|
||||
Extracts the components of this color.
|
||||
|
||||
The size and values of this array depends on the color space. You can obtain the color space using [`space`](/docs/reference/visualize/color/#definitions-space). Below is a table of the color spaces and their components:
|
||||
|
||||
| Color space | C1 | C2 | C3 | C4 |
|
||||
| --- | --- | --- | --- | --- |
|
||||
| [`luma`](/docs/reference/visualize/color/#definitions-luma) | Lightness | | | |
|
||||
| [`oklab`](/docs/reference/visualize/color/#definitions-oklab) | Lightness | `a` | `b` | Alpha |
|
||||
| [`oklch`](/docs/reference/visualize/color/#definitions-oklch) | Lightness | Chroma | Hue | Alpha |
|
||||
| [`linear-rgb`](/docs/reference/visualize/color/#definitions-linear-rgb) | Red | Green | Blue | Alpha |
|
||||
| [`rgb`](/docs/reference/visualize/color/#definitions-rgb) | Red | Green | Blue | Alpha |
|
||||
| [`cmyk`](/docs/reference/visualize/color/#definitions-cmyk) | Cyan | Magenta | Yellow | Key |
|
||||
| [`hsl`](/docs/reference/visualize/color/#definitions-hsl) | Hue | Saturation | Lightness | Alpha |
|
||||
| [`hsv`](/docs/reference/visualize/color/#definitions-hsv) | Hue | Saturation | Value | Alpha |
|
||||
|
||||
For the meaning and type of each individual value, see the documentation of the corresponding color space. The alpha component is optional and only included if the `alpha` argument is `true`. The length of the returned array depends on the number of components and whether the alpha component is included.
|
||||
|
||||
```typst
|
||||
// note that the alpha component is included by default
|
||||
#rgb(40%, 60%, 80%).components()
|
||||
```
|
||||
|
||||
```typst
|
||||
#color.components(
|
||||
alpha: bool
|
||||
) -> array
|
||||
```
|
||||
|
||||
### Parameters
|
||||
|
||||
- alpha:
|
||||
- description: Whether to include the alpha component.
|
||||
- type: bool
|
||||
- default: true
|
||||
|
||||
## color.space
|
||||
|
||||
Returns the constructor function for this color's space.
|
||||
|
||||
Returns one of:
|
||||
|
||||
- [`luma`](/docs/reference/visualize/color/#definitions-luma)
|
||||
- [`oklab`](/docs/reference/visualize/color/#definitions-oklab)
|
||||
- [`oklch`](/docs/reference/visualize/color/#definitions-oklch)
|
||||
- [`linear-rgb`](/docs/reference/visualize/color/#definitions-linear-rgb)
|
||||
- [`rgb`](/docs/reference/visualize/color/#definitions-rgb)
|
||||
- [`cmyk`](/docs/reference/visualize/color/#definitions-cmyk)
|
||||
- [`hsl`](/docs/reference/visualize/color/#definitions-hsl)
|
||||
- [`hsv`](/docs/reference/visualize/color/#definitions-hsv)
|
||||
|
||||
```typst
|
||||
#let color = cmyk(1%, 2%, 3%, 4%)
|
||||
#(color.space() == cmyk)
|
||||
```
|
||||
|
||||
## color.to-hex
|
||||
|
||||
Returns the color's RGB(A) hex representation (such as `#ffaa32` or `#020304fe`). The alpha component (last two digits in `#020304fe`) is omitted if it is equal to `ff` (255 / 100%).
|
||||
|
||||
## color.lighten
|
||||
|
||||
Lightens a color by a given factor.
|
||||
|
||||
```typst
|
||||
#color.lighten(
|
||||
factor
|
||||
) -> color
|
||||
```
|
||||
|
||||
### Parameters
|
||||
|
||||
- factor:
|
||||
- description: The factor to lighten the color by.
|
||||
- type: ratio
|
||||
- default: None
|
||||
|
||||
## color.darken
|
||||
|
||||
Darkens a color by a given factor.
|
||||
|
||||
```typst
|
||||
#color.darken(
|
||||
factor
|
||||
) -> color
|
||||
```
|
||||
|
||||
### Parameters
|
||||
|
||||
- factor:
|
||||
- description: The factor to darken the color by.
|
||||
- type: ratio
|
||||
- default: None
|
||||
|
||||
## color.saturate
|
||||
|
||||
Increases the saturation of a color by a given factor.
|
||||
|
||||
```typst
|
||||
#color.saturate(
|
||||
factor
|
||||
) -> color
|
||||
```
|
||||
|
||||
### Parameters
|
||||
|
||||
- factor:
|
||||
- description: The factor to saturate the color by.
|
||||
- type: ratio
|
||||
- default: None
|
||||
|
||||
## color.desaturate
|
||||
|
||||
Decreases the saturation of a color by a given factor.
|
||||
|
||||
```typst
|
||||
#color.desaturate(
|
||||
factor
|
||||
) -> color
|
||||
```
|
||||
|
||||
### Parameters
|
||||
|
||||
- factor:
|
||||
- description: The factor to desaturate the color by.
|
||||
- type: ratio
|
||||
- default: None
|
||||
|
||||
## color.negate
|
||||
|
||||
Produces the complementary color using a provided color space. You can think of it as the opposite side on a color wheel.
|
||||
|
||||
```typst
|
||||
#square(fill: yellow)
|
||||
#square(fill: yellow.negate())
|
||||
#square(fill: yellow.negate(space: rgb))
|
||||
```
|
||||
|
||||
```typst
|
||||
#color.negate(
|
||||
space: any
|
||||
) -> color
|
||||
```
|
||||
|
||||
### Parameters
|
||||
|
||||
- space:
|
||||
- description: The color space used for the transformation. By default, a perceptual color space is used.
|
||||
- type: any
|
||||
- default: oklab
|
||||
|
||||
## color.rotate
|
||||
|
||||
Rotates the hue of the color by a given angle.
|
||||
|
||||
```typst
|
||||
#color.rotate(
|
||||
angle,
|
||||
space: any
|
||||
) -> color
|
||||
```
|
||||
|
||||
### Parameters
|
||||
|
||||
- angle:
|
||||
- description: The angle to rotate the hue by.
|
||||
- type: angle
|
||||
- default: None
|
||||
- space:
|
||||
- description: The color space used to rotate. By default, this happens in a perceptual color space ([`oklch`](/docs/reference/visualize/color/#definitions-oklch)).
|
||||
- type: any
|
||||
- default: oklch
|
||||
|
||||
## color.mix
|
||||
|
||||
Create a color by mixing two or more colors.
|
||||
|
||||
In color spaces with a hue component (hsl, hsv, oklch), only two colors can be mixed at once. Mixing more than two colors in such a space will result in an error!
|
||||
|
||||
```typst
|
||||
#set block(height: 20pt, width: 100%)
|
||||
#block(fill: red.mix(blue))
|
||||
#block(fill: red.mix(blue, space: rgb))
|
||||
#block(fill: color.mix(red, blue, white))
|
||||
#block(fill: color.mix((red, 70%), (blue, 30%)))
|
||||
```
|
||||
|
||||
```typst
|
||||
#color.mix(
|
||||
colors,
|
||||
space: any
|
||||
) -> color
|
||||
```
|
||||
|
||||
### Parameters
|
||||
|
||||
- colors:
|
||||
- description: The colors, optionally with weights, specified as a pair (array of length two) of color and weight (float or ratio). The weights do not need to add to `100%`, they are relative to the sum of all weights.
|
||||
- type: color | array
|
||||
- default: None
|
||||
- space:
|
||||
- description: The color space to mix in. By default, this happens in a perceptual color space ([`oklab`](/docs/reference/visualize/color/#definitions-oklab)).
|
||||
- type: any
|
||||
- default: oklab
|
||||
|
||||
## color.transparentize
|
||||
|
||||
Makes a color more transparent by a given factor.
|
||||
|
||||
This method is relative to the existing alpha value. If the scale is positive, calculates `alpha - alpha * scale`. Negative scales behave like `color.opacify(-scale)`.
|
||||
|
||||
```typst
|
||||
#block(fill: red)[opaque]
|
||||
#block(fill: red.transparentize(50%))[half red]
|
||||
#block(fill: red.transparentize(75%))[quarter red]
|
||||
```
|
||||
|
||||
```typst
|
||||
#color.transparentize(
|
||||
scale
|
||||
) -> color
|
||||
```
|
||||
|
||||
### Parameters
|
||||
|
||||
- scale:
|
||||
- description: The factor to change the alpha value by.
|
||||
- type: ratio
|
||||
- default: None
|
||||
|
||||
## color.opacify
|
||||
|
||||
Makes a color more opaque by a given scale.
|
||||
|
||||
This method is relative to the existing alpha value. If the scale is positive, calculates `alpha + scale - alpha * scale`. Negative scales behave like `color.transparentize(-scale)`.
|
||||
|
||||
```typst
|
||||
#let half-red = red.transparentize(50%)
|
||||
#block(fill: half-red.opacify(100%))[opaque]
|
||||
#block(fill: half-red.opacify(50%))[three quarters red]
|
||||
#block(fill: half-red.opacify(-50%))[one quarter red]
|
||||
```
|
||||
|
||||
```typst
|
||||
#color.opacify(
|
||||
scale
|
||||
) -> color
|
||||
```
|
||||
|
||||
### Parameters
|
||||
|
||||
- scale:
|
||||
- description: The scale to change the alpha value by.
|
||||
- type: ratio
|
||||
- default: None
|
||||
|
||||
|
||||
@@ -0,0 +1,260 @@
|
||||
# Curve
|
||||
|
||||
# curve
|
||||
|
||||
A curve consisting of movements, lines, and Bézier segments.
|
||||
|
||||
At any point in time, there is a conceptual pen or cursor.
|
||||
|
||||
- Move elements move the cursor without drawing.
|
||||
- Line/Quadratic/Cubic elements draw a segment from the cursor to a new position, potentially with control point for a Bézier curve.
|
||||
- Close elements draw a straight or smooth line back to the start of the curve or the latest preceding move segment.
|
||||
|
||||
For layout purposes, the bounding box of the curve is a tight rectangle containing all segments as well as the point `(0pt, 0pt)`.
|
||||
|
||||
Positions may be specified absolutely (i.e. relatively to `(0pt, 0pt)`), or relative to the current pen/cursor position, that is, the position where the previous segment ended.
|
||||
|
||||
Bézier curve control points can be skipped by passing `none` or automatically mirrored from the preceding segment by passing `auto`.
|
||||
|
||||
## Example
|
||||
|
||||
```typst
|
||||
#curve(
|
||||
fill: blue.lighten(80%),
|
||||
stroke: blue,
|
||||
curve.move((0pt, 50pt)),
|
||||
curve.line((100pt, 50pt)),
|
||||
curve.cubic(none, (90pt, 0pt), (50pt, 0pt)),
|
||||
curve.close(),
|
||||
)
|
||||
```
|
||||
|
||||
```typst
|
||||
#curve(
|
||||
fill: none | color | gradient | tiling,
|
||||
fill-rule: str,
|
||||
stroke: none | auto | length | color | gradient | stroke | tiling | dictionary,
|
||||
components
|
||||
) -> content
|
||||
```
|
||||
|
||||
## Parameters
|
||||
|
||||
- fill:
|
||||
- description: How to fill the curve. When setting a fill, the default stroke disappears. To create a curve with both fill and stroke, you have to configure both.
|
||||
- type: none | color | gradient | tiling
|
||||
- default: none
|
||||
- fill-rule:
|
||||
- description: The drawing rule used to fill the curve. ```typst // We use `.with` to get a new // function that has the common // arguments pre-applied. #let star = curve.with( fill: red, curve.move((25pt, 0pt)), curve.line((10pt, 50pt)), curve.line((50pt, 20pt)), curve.line((0pt, 20pt)), curve.line((40pt, 50pt)), curve.close(), ) #star(fill-rule: "non-zero") #star(fill-rule: "even-odd") ```
|
||||
- type: str
|
||||
- default: "non - zero"
|
||||
- stroke:
|
||||
- description: How to [stroke](/docs/reference/visualize/stroke/) the curve. Can be set to `none` to disable the stroke or to `auto` for a stroke of `1pt` black if and only if no fill is given. ```typst #let down = curve.line((40pt, 40pt), relative: true) #let up = curve.line((40pt, -40pt), relative: true) #curve( stroke: 4pt + gradient.linear(red, blue), down, up, down, up, down, ) ```
|
||||
- type: none | auto | length | color | gradient | stroke | tiling | dictionary
|
||||
- default: auto
|
||||
- components:
|
||||
- description: The components of the curve, in the form of moves, line and Bézier segment, and closes.
|
||||
- type: content
|
||||
- default: None
|
||||
|
||||
|
||||
## Definitions
|
||||
### curve.move
|
||||
|
||||
Starts a new curve component.
|
||||
|
||||
If no `curve.move` element is passed, the curve will start at `(0pt, 0pt)`.
|
||||
|
||||
```typst
|
||||
#curve(
|
||||
fill: blue.lighten(80%),
|
||||
fill-rule: "even-odd",
|
||||
stroke: blue,
|
||||
curve.line((50pt, 0pt)),
|
||||
curve.line((50pt, 50pt)),
|
||||
curve.line((0pt, 50pt)),
|
||||
curve.close(),
|
||||
curve.move((10pt, 10pt)),
|
||||
curve.line((40pt, 10pt)),
|
||||
curve.line((40pt, 40pt)),
|
||||
curve.line((10pt, 40pt)),
|
||||
curve.close(),
|
||||
)
|
||||
```
|
||||
|
||||
```typst
|
||||
#curve.move(
|
||||
start,
|
||||
relative: bool
|
||||
) -> content
|
||||
```
|
||||
|
||||
#### Parameters
|
||||
|
||||
- start:
|
||||
- description: The starting point for the new component.
|
||||
- type: array
|
||||
- default: None
|
||||
- relative:
|
||||
- description: Whether the coordinates are relative to the previous point.
|
||||
- type: bool
|
||||
- default: false
|
||||
|
||||
### curve.line
|
||||
|
||||
Adds a straight line from the current point to a following one.
|
||||
|
||||
```typst
|
||||
#curve(
|
||||
stroke: blue,
|
||||
curve.line((50pt, 0pt)),
|
||||
curve.line((50pt, 50pt)),
|
||||
curve.line((100pt, 50pt)),
|
||||
curve.line((100pt, 0pt)),
|
||||
curve.line((150pt, 0pt)),
|
||||
)
|
||||
```
|
||||
|
||||
```typst
|
||||
#curve.line(
|
||||
end,
|
||||
relative: bool
|
||||
) -> content
|
||||
```
|
||||
|
||||
#### Parameters
|
||||
|
||||
- end:
|
||||
- description: The point at which the line shall end.
|
||||
- type: array
|
||||
- default: None
|
||||
- relative:
|
||||
- description: Whether the coordinates are relative to the previous point. ```typst #curve( stroke: blue, curve.line((50pt, 0pt), relative: true), curve.line((0pt, 50pt), relative: true), curve.line((50pt, 0pt), relative: true), curve.line((0pt, -50pt), relative: true), curve.line((50pt, 0pt), relative: true), ) ```
|
||||
- type: bool
|
||||
- default: false
|
||||
|
||||
### curve.quad
|
||||
|
||||
Adds a quadratic Bézier curve segment from the last point to `end`, using `control` as the control point.
|
||||
|
||||
```typst
|
||||
// Function to illustrate where the control point is.
|
||||
#let mark((x, y)) = place(
|
||||
dx: x - 1pt, dy: y - 1pt,
|
||||
circle(fill: aqua, radius: 2pt),
|
||||
)
|
||||
|
||||
#mark((20pt, 20pt))
|
||||
|
||||
#curve(
|
||||
stroke: blue,
|
||||
curve.move((0pt, 100pt)),
|
||||
curve.quad((20pt, 20pt), (100pt, 0pt)),
|
||||
)
|
||||
```
|
||||
|
||||
```typst
|
||||
#curve.quad(
|
||||
control,
|
||||
end,
|
||||
relative: bool
|
||||
) -> content
|
||||
```
|
||||
|
||||
#### Parameters
|
||||
|
||||
- control:
|
||||
- description: The control point of the quadratic Bézier curve. - If `auto` and this segment follows another quadratic Bézier curve, the previous control point will be mirrored. - If `none`, the control point defaults to `end`, and the curve will be a straight line. ```typst #curve( stroke: 2pt, curve.quad((20pt, 40pt), (40pt, 40pt), relative: true), curve.quad(auto, (40pt, -40pt), relative: true), ) ```
|
||||
- type: none | auto | array
|
||||
- default: None
|
||||
- end:
|
||||
- description: The point at which the segment shall end.
|
||||
- type: array
|
||||
- default: None
|
||||
- relative:
|
||||
- description: Whether the `control` and `end` coordinates are relative to the previous point.
|
||||
- type: bool
|
||||
- default: false
|
||||
|
||||
### curve.cubic
|
||||
|
||||
Adds a cubic Bézier curve segment from the last point to `end`, using `control-start` and `control-end` as the control points.
|
||||
|
||||
```typst
|
||||
// Function to illustrate where the control points are.
|
||||
#let handle(start, end) = place(
|
||||
line(stroke: red, start: start, end: end)
|
||||
)
|
||||
|
||||
#handle((0pt, 80pt), (10pt, 20pt))
|
||||
#handle((90pt, 60pt), (100pt, 0pt))
|
||||
|
||||
#curve(
|
||||
stroke: blue,
|
||||
curve.move((0pt, 80pt)),
|
||||
curve.cubic((10pt, 20pt), (90pt, 60pt), (100pt, 0pt)),
|
||||
)
|
||||
```
|
||||
|
||||
```typst
|
||||
#curve.cubic(
|
||||
control-start,
|
||||
control-end,
|
||||
end,
|
||||
relative: bool
|
||||
) -> content
|
||||
```
|
||||
|
||||
#### Parameters
|
||||
|
||||
- control-start:
|
||||
- description: The control point going out from the start of the curve segment. - If `auto` and this element follows another `curve.cubic` element, the last control point will be mirrored. In SVG terms, this makes `curve.cubic` behave like the `S` operator instead of the `C` operator. - If `none`, the curve has no first control point, or equivalently, the control point defaults to the curve\'s starting point. ```typst #curve( stroke: blue, curve.move((0pt, 50pt)), // - No start control point // - End control point at `(20pt, 0pt)` // - End point at `(50pt, 0pt)` curve.cubic(none, (20pt, 0pt), (50pt, 0pt)), // - No start control point // - No end control point // - End point at `(50pt, 0pt)` curve.cubic(none, none, (100pt, 50pt)), ) #curve( stroke: blue, curve.move((0pt, 50pt)), curve.cubic(none, (20pt, 0pt), (50pt, 0pt)), // Passing `auto` instead of `none` means the start control point // mirrors the end control point of the previous curve. Mirror of // `(20pt, 0pt)` w.r.t `(50pt, 0pt)` is `(80pt, 0pt)`. curve.cubic(auto, none, (100pt, 50pt)), ) #curve( stroke: blue, curve.move((0pt, 50pt)), curve.cubic(none, (20pt, 0pt), (50pt, 0pt)), // `(80pt, 0pt)` is the same as `auto` in this case. curve.cubic((80pt, 0pt), none, (100pt, 50pt)), ) ```
|
||||
- type: none | auto | array
|
||||
- default: None
|
||||
- control-end:
|
||||
- description: The control point going into the end point of the curve segment. If set to `none`, the curve has no end control point, or equivalently, the control point defaults to the curve\'s end point.
|
||||
- type: none | array
|
||||
- default: None
|
||||
- end:
|
||||
- description: The point at which the curve segment shall end.
|
||||
- type: array
|
||||
- default: None
|
||||
- relative:
|
||||
- description: Whether the `control-start`, `control-end`, and `end` coordinates are relative to the previous point.
|
||||
- type: bool
|
||||
- default: false
|
||||
|
||||
### curve.close
|
||||
|
||||
Closes the curve by adding a segment from the last point to the start of the curve (or the last preceding `curve.move` point).
|
||||
|
||||
```typst
|
||||
// We define a function to show the same shape with
|
||||
// both closing modes.
|
||||
#let shape(mode: "smooth") = curve(
|
||||
fill: blue.lighten(80%),
|
||||
stroke: blue,
|
||||
curve.move((0pt, 50pt)),
|
||||
curve.line((100pt, 50pt)),
|
||||
curve.cubic(auto, (90pt, 0pt), (50pt, 0pt)),
|
||||
curve.close(mode: mode),
|
||||
)
|
||||
|
||||
#shape(mode: "smooth")
|
||||
#shape(mode: "straight")
|
||||
```
|
||||
|
||||
```typst
|
||||
#curve.close(
|
||||
mode: str
|
||||
) -> content
|
||||
```
|
||||
|
||||
#### Parameters
|
||||
|
||||
- mode:
|
||||
- description: How to close the curve.
|
||||
- type: str
|
||||
- default: "smooth"
|
||||
|
||||
|
||||
@@ -0,0 +1,64 @@
|
||||
# Ellipse
|
||||
|
||||
# ellipse
|
||||
|
||||
An ellipse with optional content.
|
||||
|
||||
## Example
|
||||
|
||||
```typst
|
||||
// Without content.
|
||||
#ellipse(width: 35%, height: 30pt)
|
||||
|
||||
// With content.
|
||||
#ellipse[
|
||||
#set align(center)
|
||||
Automatically sized \
|
||||
to fit the content.
|
||||
]
|
||||
```
|
||||
|
||||
```typst
|
||||
#ellipse(
|
||||
width: auto | relative,
|
||||
height: auto | relative | fraction,
|
||||
fill: none | color | gradient | tiling,
|
||||
stroke: none | auto | length | color | gradient | stroke | tiling | dictionary,
|
||||
inset: relative | dictionary,
|
||||
outset: relative | dictionary,
|
||||
body
|
||||
) -> content
|
||||
```
|
||||
|
||||
## Parameters
|
||||
|
||||
- width:
|
||||
- description: The ellipse\'s width, relative to its parent container.
|
||||
- type: auto | relative
|
||||
- default: auto
|
||||
- height:
|
||||
- description: The ellipse\'s height, relative to its parent container.
|
||||
- type: auto | relative | fraction
|
||||
- default: auto
|
||||
- fill:
|
||||
- description: How to fill the ellipse. See the [rectangle\'s documentation](/docs/reference/visualize/rect/#parameters-fill) for more details.
|
||||
- type: none | color | gradient | tiling
|
||||
- default: none
|
||||
- stroke:
|
||||
- description: How to stroke the ellipse. See the [rectangle\'s documentation](/docs/reference/visualize/rect/#parameters-stroke) for more details.
|
||||
- type: none | auto | length | color | gradient | stroke | tiling | dictionary
|
||||
- default: auto
|
||||
- inset:
|
||||
- description: How much to pad the ellipse\'s content. See the [box\'s documentation](/docs/reference/layout/box/#parameters-inset) for more details.
|
||||
- type: relative | dictionary
|
||||
- default: 0 % + 5pt
|
||||
- outset:
|
||||
- description: How much to expand the ellipse\'s size without affecting the layout. See the [box\'s documentation](/docs/reference/layout/box/#parameters-outset) for more details.
|
||||
- type: relative | dictionary
|
||||
- default: (:)
|
||||
- body:
|
||||
- description: The content to place into the ellipse. When this is omitted, the ellipse takes on a default size of at most `45pt` by `30pt`.
|
||||
- type: none | content
|
||||
- default: none
|
||||
|
||||
|
||||
@@ -0,0 +1,406 @@
|
||||
# Gradient
|
||||
|
||||
A color gradient.
|
||||
|
||||
Typst supports linear gradients through the [`gradient.linear` function](/docs/reference/visualize/gradient/#definitions-linear), radial gradients through the [`gradient.radial` function](/docs/reference/visualize/gradient/#definitions-radial), and conic gradients through the [`gradient.conic` function](/docs/reference/visualize/gradient/#definitions-conic).
|
||||
|
||||
A gradient can be used for the following purposes:
|
||||
|
||||
- As a fill to paint the interior of a shape: `rect(fill: gradient.linear(..))`
|
||||
- As a stroke to paint the outline of a shape: `rect(stroke: 1pt + gradient.linear(..))`
|
||||
- As the fill of text: `set text(fill: gradient.linear(..))`
|
||||
- As a color map you can [sample](/docs/reference/visualize/gradient/#definitions-sample) from: `gradient.linear(..).sample(50%)`
|
||||
|
||||
## Examples
|
||||
|
||||
```typst
|
||||
#stack(
|
||||
dir: ltr,
|
||||
spacing: 1fr,
|
||||
square(fill: gradient.linear(..color.map.rainbow)),
|
||||
square(fill: gradient.radial(..color.map.rainbow)),
|
||||
square(fill: gradient.conic(..color.map.rainbow)),
|
||||
)
|
||||
```
|
||||
|
||||
Gradients are also supported on text, but only when setting the [relativeness](/docs/reference/visualize/gradient/#definitions-relative) to either `auto` (the default value) or `"parent"`. To create word-by-word or glyph-by-glyph gradients, you can wrap the words or characters of your text in [boxes](/docs/reference/layout/box/) manually or through a [show rule](/docs/reference/styling/#show-rules).
|
||||
|
||||
```typst
|
||||
#set text(fill: gradient.linear(red, blue))
|
||||
#let rainbow(content) = {
|
||||
set text(fill: gradient.linear(..color.map.rainbow))
|
||||
box(content)
|
||||
}
|
||||
|
||||
This is a gradient on text, but with a #rainbow[twist]!
|
||||
```
|
||||
|
||||
## Stops
|
||||
|
||||
A gradient is composed of a series of stops. Each of these stops has a color and an offset. The offset is a [ratio](/docs/reference/layout/ratio/) between `0%` and `100%` or an angle between `0deg` and `360deg`. The offset is a relative position that determines how far along the gradient the stop is located. The stop's color is the color of the gradient at that position. You can choose to omit the offsets when defining a gradient. In this case, Typst will space all stops evenly.
|
||||
|
||||
Typst predefines color maps that you can use as stops. See the [`color`](/docs/reference/visualize/color/#predefined-color-maps) documentation for more details.
|
||||
|
||||
## Relativeness
|
||||
|
||||
The location of the `0%` and `100%` stops depends on the dimensions of a container. This container can either be the shape that it is being painted on, or the closest surrounding container. This is controlled by the `relative` argument of a gradient constructor. By default, gradients are relative to the shape they are being painted on, unless the gradient is applied on text, in which case they are relative to the closest ancestor container.
|
||||
|
||||
Typst determines the ancestor container as follows:
|
||||
|
||||
- For shapes that are placed at the root/top level of the document, the closest ancestor is the page itself.
|
||||
- For other shapes, the ancestor is the innermost [`block`](/docs/reference/layout/block/) or [`box`](/docs/reference/layout/box/) that contains the shape. This includes the boxes and blocks that are implicitly created by show rules and elements. For example, a [`rotate`](/docs/reference/layout/rotate/) will not affect the parent of a gradient, but a [`grid`](/docs/reference/layout/grid/) will.
|
||||
|
||||
## Color spaces and interpolation
|
||||
|
||||
Gradients can be interpolated in any color space. By default, gradients are interpolated in the [Oklab](/docs/reference/visualize/color/#definitions-oklab) color space, which is a [perceptually uniform](https://programmingdesignsystems.com/color/perceptually-uniform-color-spaces/index.html) color space. This means that the gradient will be perceived as having a smooth progression of colors. This is particularly useful for data visualization.
|
||||
|
||||
However, you can choose to interpolate the gradient in any supported color space you want, but beware that some color spaces are not suitable for perceptually interpolating between colors. Consult the table below when choosing an interpolation space.
|
||||
|
||||
| Color space | Perceptually uniform? |
|
||||
| --- | --- |
|
||||
| [Oklab](/docs/reference/visualize/color/#definitions-oklab) | _Yes_ |
|
||||
| [Oklch](/docs/reference/visualize/color/#definitions-oklch) | _Yes_ |
|
||||
| [sRGB](/docs/reference/visualize/color/#definitions-rgb) | _No_ |
|
||||
| [linear-RGB](/docs/reference/visualize/color/#definitions-linear-rgb) | _Yes_ |
|
||||
| [CMYK](/docs/reference/visualize/color/#definitions-cmyk) | _No_ |
|
||||
| [Grayscale](/docs/reference/visualize/color/#definitions-luma) | _Yes_ |
|
||||
| [HSL](/docs/reference/visualize/color/#definitions-hsl) | _No_ |
|
||||
| [HSV](/docs/reference/visualize/color/#definitions-hsv) | _No_ |
|
||||
|
||||
## Direction
|
||||
|
||||
Some gradients are sensitive to direction. For example, a linear gradient has an angle that determines its direction. Typst uses a clockwise angle, with 0° being from left to right, 90° from top to bottom, 180° from right to left, and 270° from bottom to top.
|
||||
|
||||
```typst
|
||||
#stack(
|
||||
dir: ltr,
|
||||
spacing: 1fr,
|
||||
square(fill: gradient.linear(red, blue, angle: 0deg)),
|
||||
square(fill: gradient.linear(red, blue, angle: 90deg)),
|
||||
square(fill: gradient.linear(red, blue, angle: 180deg)),
|
||||
square(fill: gradient.linear(red, blue, angle: 270deg)),
|
||||
)
|
||||
```
|
||||
|
||||
## Note on file sizes
|
||||
|
||||
Gradients can be quite large, especially if they have many stops. This is because gradients are stored as a list of colors and offsets, which can take up a lot of space. If you are concerned about file sizes, you should consider the following:
|
||||
|
||||
- SVG gradients are currently inefficiently encoded. This will be improved in the future.
|
||||
- PDF gradients in the [`color.oklab`](/docs/reference/visualize/color/#definitions-oklab), [`color.hsv`](/docs/reference/visualize/color/#definitions-hsv), [`color.hsl`](/docs/reference/visualize/color/#definitions-hsl), and [`color.oklch`](/docs/reference/visualize/color/#definitions-oklch) color spaces are stored as a list of [`color.rgb`](/docs/reference/visualize/color/#definitions-rgb) colors with extra stops in between. This avoids needing to encode these color spaces in your PDF file, but it does add extra stops to your gradient, which can increase the file size.
|
||||
|
||||
|
||||
## Methods
|
||||
|
||||
## gradient.linear
|
||||
|
||||
Creates a new linear gradient, in which colors transition along a straight line.
|
||||
|
||||
```typst
|
||||
#rect(
|
||||
width: 100%,
|
||||
height: 20pt,
|
||||
fill: gradient.linear(
|
||||
..color.map.viridis,
|
||||
),
|
||||
)
|
||||
```
|
||||
|
||||
```typst
|
||||
#gradient.linear(
|
||||
stops,
|
||||
space: any,
|
||||
relative: auto | str,
|
||||
dir,
|
||||
angle
|
||||
) -> gradient
|
||||
```
|
||||
|
||||
### Parameters
|
||||
|
||||
- stops:
|
||||
- description: The color [stops](#stops) of the gradient.
|
||||
- type: color | array
|
||||
- default: None
|
||||
- space:
|
||||
- description: The color space in which to interpolate the gradient. Defaults to a perceptually uniform color space called [Oklab](/docs/reference/visualize/color/#definitions-oklab).
|
||||
- type: any
|
||||
- default: oklab
|
||||
- relative:
|
||||
- description: The [relative placement](#relativeness) of the gradient. For an element placed at the root/top level of the document, the parent is the page itself. For other elements, the parent is the innermost block, box, column, grid, or stack that contains the element.
|
||||
- type: auto | str
|
||||
- default: auto
|
||||
- dir:
|
||||
- description: The direction of the gradient.
|
||||
- type: direction
|
||||
- default: ltr
|
||||
- angle:
|
||||
- description: The angle of the gradient.
|
||||
- type: angle
|
||||
- default: None
|
||||
|
||||
## gradient.radial
|
||||
|
||||
Creates a new radial gradient, in which colors radiate away from an origin.
|
||||
|
||||
The gradient is defined by two circles: the focal circle and the end circle. The focal circle is a circle with center `focal-center` and radius `focal-radius`, that defines the points at which the gradient starts and has the color of the first stop. The end circle is a circle with center `center` and radius `radius`, that defines the points at which the gradient ends and has the color of the last stop. The gradient is then interpolated between these two circles.
|
||||
|
||||
Using these four values, also called the focal point for the starting circle and the center and radius for the end circle, we can define a gradient with more interesting properties than a basic radial gradient.
|
||||
|
||||
```typst
|
||||
#stack(
|
||||
dir: ltr,
|
||||
spacing: 1fr,
|
||||
circle(fill: gradient.radial(
|
||||
..color.map.viridis,
|
||||
)),
|
||||
circle(fill: gradient.radial(
|
||||
..color.map.viridis,
|
||||
focal-center: (10%, 40%),
|
||||
focal-radius: 5%,
|
||||
)),
|
||||
)
|
||||
```
|
||||
|
||||
```typst
|
||||
#gradient.radial(
|
||||
stops,
|
||||
space: any,
|
||||
relative: auto | str,
|
||||
center: array,
|
||||
radius: ratio,
|
||||
focal-center: auto | array,
|
||||
focal-radius: ratio
|
||||
) -> gradient
|
||||
```
|
||||
|
||||
### Parameters
|
||||
|
||||
- stops:
|
||||
- description: The color [stops](#stops) of the gradient.
|
||||
- type: color | array
|
||||
- default: None
|
||||
- space:
|
||||
- description: The color space in which to interpolate the gradient. Defaults to a perceptually uniform color space called [Oklab](/docs/reference/visualize/color/#definitions-oklab).
|
||||
- type: any
|
||||
- default: oklab
|
||||
- relative:
|
||||
- description: The [relative placement](#relativeness) of the gradient. For an element placed at the root/top level of the document, the parent is the page itself. For other elements, the parent is the innermost block, box, column, grid, or stack that contains the element.
|
||||
- type: auto | str
|
||||
- default: auto
|
||||
- center:
|
||||
- description: The center of the end circle of the gradient. A value of `(50%, 50%)` means that the end circle is centered inside of its container.
|
||||
- type: array
|
||||
- default: (50 % , 50 % )
|
||||
- radius:
|
||||
- description: The radius of the end circle of the gradient. By default, it is set to `50%`. The ending radius must be bigger than the focal radius.
|
||||
- type: ratio
|
||||
- default: 50 %
|
||||
- focal-center:
|
||||
- description: The center of the focal circle of the gradient. The focal center must be inside of the end circle. A value of `(50%, 50%)` means that the focal circle is centered inside of its container. By default it is set to the same as the center of the last circle.
|
||||
- type: auto | array
|
||||
- default: auto
|
||||
- focal-radius:
|
||||
- description: The radius of the focal circle of the gradient. The focal center must be inside of the end circle. By default, it is set to `0%`. The focal radius must be smaller than the ending radius\\`.
|
||||
- type: ratio
|
||||
- default: 0 %
|
||||
|
||||
## gradient.conic
|
||||
|
||||
Creates a new conic gradient, in which colors change radially around a center point.
|
||||
|
||||
You can control the center point of the gradient by using the `center` argument. By default, the center point is the center of the shape.
|
||||
|
||||
```typst
|
||||
#stack(
|
||||
dir: ltr,
|
||||
spacing: 1fr,
|
||||
circle(fill: gradient.conic(
|
||||
..color.map.viridis,
|
||||
)),
|
||||
circle(fill: gradient.conic(
|
||||
..color.map.viridis,
|
||||
center: (20%, 30%),
|
||||
)),
|
||||
)
|
||||
```
|
||||
|
||||
```typst
|
||||
#gradient.conic(
|
||||
stops,
|
||||
angle: angle,
|
||||
space: any,
|
||||
relative: auto | str,
|
||||
center: array
|
||||
) -> gradient
|
||||
```
|
||||
|
||||
### Parameters
|
||||
|
||||
- stops:
|
||||
- description: The color [stops](#stops) of the gradient.
|
||||
- type: color | array
|
||||
- default: None
|
||||
- angle:
|
||||
- description: The angle of the gradient.
|
||||
- type: angle
|
||||
- default: 0deg
|
||||
- space:
|
||||
- description: The color space in which to interpolate the gradient. Defaults to a perceptually uniform color space called [Oklab](/docs/reference/visualize/color/#definitions-oklab).
|
||||
- type: any
|
||||
- default: oklab
|
||||
- relative:
|
||||
- description: The [relative placement](#relativeness) of the gradient. For an element placed at the root/top level of the document, the parent is the page itself. For other elements, the parent is the innermost block, box, column, grid, or stack that contains the element.
|
||||
- type: auto | str
|
||||
- default: auto
|
||||
- center:
|
||||
- description: The center of the circle of the gradient. A value of `(50%, 50%)` means that the circle is centered inside of its container.
|
||||
- type: array
|
||||
- default: (50 % , 50 % )
|
||||
|
||||
## gradient.sharp
|
||||
|
||||
Creates a sharp version of this gradient.
|
||||
|
||||
Sharp gradients have discrete jumps between colors, instead of a smooth transition. They are particularly useful for creating color lists for a preset gradient.
|
||||
|
||||
```typst
|
||||
#set rect(width: 100%, height: 20pt)
|
||||
#let grad = gradient.linear(..color.map.rainbow)
|
||||
#rect(fill: grad)
|
||||
#rect(fill: grad.sharp(5))
|
||||
#rect(fill: grad.sharp(5, smoothness: 20%))
|
||||
```
|
||||
|
||||
```typst
|
||||
#gradient.sharp(
|
||||
steps,
|
||||
smoothness: ratio
|
||||
) -> gradient
|
||||
```
|
||||
|
||||
### Parameters
|
||||
|
||||
- steps:
|
||||
- description: The number of stops in the gradient.
|
||||
- type: int
|
||||
- default: None
|
||||
- smoothness:
|
||||
- description: How much to smooth the gradient.
|
||||
- type: ratio
|
||||
- default: 0 %
|
||||
|
||||
## gradient.repeat
|
||||
|
||||
Repeats this gradient a given number of times, optionally mirroring it at every second repetition.
|
||||
|
||||
```typst
|
||||
#circle(
|
||||
radius: 40pt,
|
||||
fill: gradient
|
||||
.radial(aqua, white)
|
||||
.repeat(4),
|
||||
)
|
||||
```
|
||||
|
||||
```typst
|
||||
#gradient.repeat(
|
||||
repetitions,
|
||||
mirror: bool
|
||||
) -> gradient
|
||||
```
|
||||
|
||||
### Parameters
|
||||
|
||||
- repetitions:
|
||||
- description: The number of times to repeat the gradient.
|
||||
- type: int
|
||||
- default: None
|
||||
- mirror:
|
||||
- description: Whether to mirror the gradient at every second repetition, i.e., the first instance (and all odd ones) stays unchanged. ```typst #circle( radius: 40pt, fill: gradient .conic(green, black) .repeat(2, mirror: true) ) ```
|
||||
- type: bool
|
||||
- default: false
|
||||
|
||||
## gradient.kind
|
||||
|
||||
Returns the kind of this gradient.
|
||||
|
||||
## gradient.stops
|
||||
|
||||
Returns the stops of this gradient.
|
||||
|
||||
## gradient.space
|
||||
|
||||
Returns the mixing space of this gradient.
|
||||
|
||||
## gradient.relative
|
||||
|
||||
Returns the relative placement of this gradient.
|
||||
|
||||
## gradient.angle
|
||||
|
||||
Returns the angle of this gradient.
|
||||
|
||||
Returns `none` if the gradient is neither linear nor conic.
|
||||
|
||||
## gradient.center
|
||||
|
||||
Returns the center of this gradient.
|
||||
|
||||
Returns `none` if the gradient is neither radial nor conic.
|
||||
|
||||
## gradient.radius
|
||||
|
||||
Returns the radius of this gradient.
|
||||
|
||||
Returns `none` if the gradient is not radial.
|
||||
|
||||
## gradient.focal-center
|
||||
|
||||
Returns the focal-center of this gradient.
|
||||
|
||||
Returns `none` if the gradient is not radial.
|
||||
|
||||
## gradient.focal-radius
|
||||
|
||||
Returns the focal-radius of this gradient.
|
||||
|
||||
Returns `none` if the gradient is not radial.
|
||||
|
||||
## gradient.sample
|
||||
|
||||
Sample the gradient at a given position.
|
||||
|
||||
The position is either a position along the gradient (a [ratio](/docs/reference/layout/ratio/) between `0%` and `100%`) or an [angle](/docs/reference/layout/angle/). Any value outside of this range will be clamped.
|
||||
|
||||
```typst
|
||||
#gradient.sample(
|
||||
t
|
||||
) -> color
|
||||
```
|
||||
|
||||
### Parameters
|
||||
|
||||
- t:
|
||||
- description: The position at which to sample the gradient.
|
||||
- type: angle | ratio
|
||||
- default: None
|
||||
|
||||
## gradient.samples
|
||||
|
||||
Samples the gradient at multiple positions at once and returns the results as an array.
|
||||
|
||||
```typst
|
||||
#gradient.samples(
|
||||
ts
|
||||
) -> array
|
||||
```
|
||||
|
||||
### Parameters
|
||||
|
||||
- ts:
|
||||
- description: The positions at which to sample the gradient.
|
||||
- type: angle | ratio
|
||||
- default: None
|
||||
|
||||
|
||||
@@ -0,0 +1,125 @@
|
||||
# Image
|
||||
|
||||
# image
|
||||
|
||||
A raster or vector graphic.
|
||||
|
||||
You can wrap the image in a [`figure`](/docs/reference/model/figure/) to give it a number and caption.
|
||||
|
||||
Like most elements, images are _block-level_ by default and thus do not integrate themselves into adjacent paragraphs. To force an image to become inline, put it into a [`box`](/docs/reference/layout/box/).
|
||||
|
||||
## Example
|
||||
|
||||
```typst
|
||||
#figure(
|
||||
image("molecular.jpg", width: 80%),
|
||||
caption: [
|
||||
A step in the molecular testing
|
||||
pipeline of our lab.
|
||||
],
|
||||
)
|
||||
```
|
||||
|
||||
```typst
|
||||
#image(
|
||||
source,
|
||||
format: auto | str | dictionary,
|
||||
width: auto | relative,
|
||||
height: auto | relative | fraction,
|
||||
alt: none | str,
|
||||
page: int,
|
||||
fit: str,
|
||||
scaling: auto | str,
|
||||
icc: auto | str | bytes
|
||||
) -> content
|
||||
```
|
||||
|
||||
## Parameters
|
||||
|
||||
- source:
|
||||
- description: A [path](/docs/reference/syntax/#paths) to an image file or raw bytes making up an image in one of the supported [formats](/docs/reference/visualize/image/#parameters-format). Bytes can be used to specify raw pixel data in a row-major, left-to-right, top-to-bottom format. ```typst #let original = read("diagram.svg") #let changed = original.replace( "#2B80FF", // blue green.to-hex(), ) #image(bytes(original)) #image(bytes(changed)) ```
|
||||
- type: str | bytes
|
||||
- default: None
|
||||
- format:
|
||||
- description: The image\'s format. By default, the format is detected automatically. Typically, you thus only need to specify this when providing raw bytes as the [`source`](/docs/reference/visualize/image/#parameters-source) (even then, Typst will try to figure out the format automatically, but that\'s not always possible). Supported formats are `"png"`, `"jpg"`, `"gif"`, `"svg"`, `"pdf"`, `"webp"` as well as raw pixel data. Note that several restrictions apply when using PDF files as images: - When exporting to PDF, any PDF image file used must have a version equal to or lower than the [export target PDF version](/docs/reference/pdf/#pdf-versions). - PDF files as images are currently not supported when exporting with a specific PDF standard, like PDF/A-3 or PDF/UA-1. In these cases, you can instead use SVGs to embed vector images. - The image file must not be password-protected. - Tags in your PDF image will not be preserved. Instead, you must provide an [alternative description](/docs/reference/visualize/image/#parameters-alt) to make the image accessible. When providing raw pixel data as the `source`, you must specify a dictionary with the following keys as the `format`: - `encoding` ([str](/docs/reference/foundations/str/)): The encoding of the pixel data. One of: - `"rgb8"` (three 8-bit channels: red, green, blue) - `"rgba8"` (four 8-bit channels: red, green, blue, alpha) - `"luma8"` (one 8-bit channel) - `"lumaa8"` (two 8-bit channels: luma and alpha) - `width` ([int](/docs/reference/foundations/int/)): The pixel width of the image. - `height` ([int](/docs/reference/foundations/int/)): The pixel height of the image. The pixel width multiplied by the height multiplied by the channel count for the specified encoding must then match the `source` data. ```typst #image( read( "tetrahedron.svg", encoding: none, ), format: "svg", width: 2cm, ) #image( bytes(range(16).map(x => x * 16)), format: ( encoding: "luma8", width: 4, height: 4, ), width: 2cm, ) ```
|
||||
- type: auto | str | dictionary
|
||||
- default: auto
|
||||
- width:
|
||||
- description: The width of the image.
|
||||
- type: auto | relative
|
||||
- default: auto
|
||||
- height:
|
||||
- description: The height of the image.
|
||||
- type: auto | relative | fraction
|
||||
- default: auto
|
||||
- alt:
|
||||
- description: An alternative description of the image. This text is used by Assistive Technology (AT) like screen readers to describe the image to users with visual impairments. When the image is wrapped in a [`figure`](/docs/reference/model/figure/), use this parameter rather than the [figure\'s `alt` parameter](/docs/reference/model/figure/#parameters-alt) to describe the image. The only exception to this rule is when the image and the other contents in the figure form a single semantic unit. In this case, use the figure\'s `alt` parameter to describe the entire composition and do not use this parameter. You can learn how to write good alternative descriptions in the [Accessibility Guide](/docs/guides/accessibility/#textual-representations).
|
||||
- type: none | str
|
||||
- default: none
|
||||
- page:
|
||||
- description: The page number that should be embedded as an image. This attribute only has an effect for PDF files.
|
||||
- type: int
|
||||
- default: 1
|
||||
- fit:
|
||||
- description: How the image should adjust itself to a given area (the area is defined by the `width` and `height` fields). Note that `fit` doesn\'t visually change anything if the area\'s aspect ratio is the same as the image\'s one. ```typst #set page(width: 300pt, height: 50pt, margin: 10pt) #image("tiger.jpg", width: 100%, fit: "cover") #image("tiger.jpg", width: 100%, fit: "contain") #image("tiger.jpg", width: 100%, fit: "stretch") ```
|
||||
- type: str
|
||||
- default: "cover"
|
||||
- scaling:
|
||||
- description: A hint to viewers how they should scale the image. When set to `auto`, the default is left up to the viewer. For PNG export, Typst will default to smooth scaling, like most PDF and SVG viewers. _Note:_ The exact look may differ across PDF viewers.
|
||||
- type: auto | str
|
||||
- default: auto
|
||||
- icc:
|
||||
- description: An ICC profile for the image. ICC profiles define how to interpret the colors in an image. When set to `auto`, Typst will try to extract an ICC profile from the image.
|
||||
- type: auto | str | bytes
|
||||
- default: auto
|
||||
|
||||
|
||||
## Definitions
|
||||
### image.decode
|
||||
|
||||
Decode a raster or vector graphic from bytes or a string.
|
||||
|
||||
```typst
|
||||
#image.decode(
|
||||
data,
|
||||
format: auto | str | dictionary,
|
||||
width: auto | relative,
|
||||
height: auto | relative | fraction,
|
||||
alt: none | str,
|
||||
fit: str,
|
||||
scaling: auto | str
|
||||
) -> content
|
||||
```
|
||||
|
||||
#### Parameters
|
||||
|
||||
- data:
|
||||
- description: The data to decode as an image. Can be a string for SVGs.
|
||||
- type: str | bytes
|
||||
- default: None
|
||||
- format:
|
||||
- description: The image\'s format. Detected automatically by default.
|
||||
- type: auto | str | dictionary
|
||||
- default: None
|
||||
- width:
|
||||
- description: The width of the image.
|
||||
- type: auto | relative
|
||||
- default: None
|
||||
- height:
|
||||
- description: The height of the image.
|
||||
- type: auto | relative | fraction
|
||||
- default: None
|
||||
- alt:
|
||||
- description: A text describing the image.
|
||||
- type: none | str
|
||||
- default: None
|
||||
- fit:
|
||||
- description: How the image should adjust itself to a given area.
|
||||
- type: str
|
||||
- default: None
|
||||
- scaling:
|
||||
- description: A hint to viewers how they should scale the image.
|
||||
- type: auto | str
|
||||
- default: None
|
||||
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
# Visualize
|
||||
|
||||
Drawing and data visualization.
|
||||
|
||||
If you want to create more advanced drawings or plots, also have a look at the [CeTZ](https://github.com/johannes-wolf/cetz) package as well as more specialized [packages](https://typst.app/universe/) for your use case.
|
||||
|
||||
## Accessibility
|
||||
|
||||
All shapes and paths drawn by Typst are automatically marked as [artifacts](/docs/reference/pdf/artifact/) to make them invisible to Assistive Technology (AT) during PDF export. However, their contents (if any) remain accessible.
|
||||
|
||||
If you are using the functions in this model to create an illustration with semantic meaning, make it accessible by wrapping it in a [`figure`](/docs/reference/model/figure/) function call. Use its [`alt` parameter](/docs/reference/model/figure/#parameters-alt) to provide an [alternative description](/docs/guides/accessibility/#textual-representations).
|
||||
|
||||
## Definitions
|
||||
|
||||
| Name | Description |
|
||||
| --- | --- |
|
||||
| [`circle`](/reference/visualize/circle/) | A circle with optional content. |
|
||||
| [`color`](/reference/visualize/color/) | A color in a specific color space. |
|
||||
| [`curve`](/reference/visualize/curve/) | A curve consisting of movements, lines, and Bézier segments. |
|
||||
| [`ellipse`](/reference/visualize/ellipse/) | An ellipse with optional content. |
|
||||
| [`gradient`](/reference/visualize/gradient/) | A color gradient. |
|
||||
| [`image`](/reference/visualize/image/) | A raster or vector graphic. |
|
||||
| [`line`](/reference/visualize/line/) | A line from one point to another. |
|
||||
| [`path`](/reference/visualize/path/) | A path through a list of points, connected by Bézier curves. |
|
||||
| [`polygon`](/reference/visualize/polygon/) | A closed polygon. |
|
||||
| [`rect`](/reference/visualize/rect/) | A rectangle with optional content. |
|
||||
| [`square`](/reference/visualize/square/) | A square with optional content. |
|
||||
| [`stroke`](/reference/visualize/stroke/) | Defines how to draw a line. |
|
||||
| [`tiling`](/reference/visualize/tiling/) | A repeating tiling fill. |
|
||||
|
||||
@@ -0,0 +1,53 @@
|
||||
# Line
|
||||
|
||||
# line
|
||||
|
||||
A line from one point to another.
|
||||
|
||||
## Example
|
||||
|
||||
```typst
|
||||
#set page(height: 100pt)
|
||||
|
||||
#line(length: 100%)
|
||||
#line(end: (50%, 50%))
|
||||
#line(
|
||||
length: 4cm,
|
||||
stroke: 2pt + maroon,
|
||||
)
|
||||
```
|
||||
|
||||
```typst
|
||||
#line(
|
||||
start: array,
|
||||
end: none | array,
|
||||
length: relative,
|
||||
angle: angle,
|
||||
stroke: length | color | gradient | stroke | tiling | dictionary
|
||||
) -> content
|
||||
```
|
||||
|
||||
## Parameters
|
||||
|
||||
- start:
|
||||
- description: The start point of the line. Must be an array of exactly two relative lengths.
|
||||
- type: array
|
||||
- default: (0 % + 0pt, 0 % + 0pt)
|
||||
- end:
|
||||
- description: The point where the line ends.
|
||||
- type: none | array
|
||||
- default: none
|
||||
- length:
|
||||
- description: The line\'s length. This is only respected if `end` is `none`.
|
||||
- type: relative
|
||||
- default: 0 % + 30pt
|
||||
- angle:
|
||||
- description: The angle at which the line points away from the origin. This is only respected if `end` is `none`.
|
||||
- type: angle
|
||||
- default: 0deg
|
||||
- stroke:
|
||||
- description: How to [stroke](/docs/reference/visualize/stroke/) the line. ```typst #set line(length: 100%) #stack( spacing: 1em, line(stroke: 2pt + red), line(stroke: (paint: blue, thickness: 4pt, cap: "round")), line(stroke: (paint: blue, thickness: 1pt, dash: "dashed")), line(stroke: (paint: blue, thickness: 1pt, dash: ("dot", 2pt, 4pt, 2pt))), ) ```
|
||||
- type: length | color | gradient | stroke | tiling | dictionary
|
||||
- default: 1pt + black
|
||||
|
||||
|
||||
@@ -0,0 +1,53 @@
|
||||
# Path
|
||||
|
||||
# path
|
||||
|
||||
A path through a list of points, connected by Bézier curves.
|
||||
|
||||
## Example
|
||||
|
||||
```typst
|
||||
#path(
|
||||
fill: blue.lighten(80%),
|
||||
stroke: blue,
|
||||
closed: true,
|
||||
(0pt, 50pt),
|
||||
(100%, 50pt),
|
||||
((50%, 0pt), (40pt, 0pt)),
|
||||
)
|
||||
```
|
||||
|
||||
```typst
|
||||
#path(
|
||||
fill: none | color | gradient | tiling,
|
||||
fill-rule: str,
|
||||
stroke: none | auto | length | color | gradient | stroke | tiling | dictionary,
|
||||
closed: bool,
|
||||
vertices
|
||||
) -> content
|
||||
```
|
||||
|
||||
## Parameters
|
||||
|
||||
- fill:
|
||||
- description: How to fill the path. When setting a fill, the default stroke disappears. To create a rectangle with both fill and stroke, you have to configure both.
|
||||
- type: none | color | gradient | tiling
|
||||
- default: none
|
||||
- fill-rule:
|
||||
- description: The drawing rule used to fill the path. ```typst // We use `.with` to get a new // function that has the common // arguments pre-applied. #let star = path.with( fill: red, closed: true, (25pt, 0pt), (10pt, 50pt), (50pt, 20pt), (0pt, 20pt), (40pt, 50pt), ) #star(fill-rule: "non-zero") #star(fill-rule: "even-odd") ```
|
||||
- type: str
|
||||
- default: "non - zero"
|
||||
- stroke:
|
||||
- description: How to [stroke](/docs/reference/visualize/stroke/) the path. Can be set to `none` to disable the stroke or to `auto` for a stroke of `1pt` black if and only if no fill is given.
|
||||
- type: none | auto | length | color | gradient | stroke | tiling | dictionary
|
||||
- default: auto
|
||||
- closed:
|
||||
- description: Whether to close this path with one last Bézier curve. This curve will take into account the adjacent control points. If you want to close with a straight line, simply add one last point that\'s the same as the start point.
|
||||
- type: bool
|
||||
- default: false
|
||||
- vertices:
|
||||
- description: The vertices of the path. Each vertex can be defined in 3 ways: - A regular point, as given to the [`line`](/docs/reference/visualize/line/) or [`polygon`](/docs/reference/visualize/polygon/) function. - An array of two points, the first being the vertex and the second being the control point. The control point is expressed relative to the vertex and is mirrored to get the second control point. The given control point is the one that affects the curve coming _into_ this vertex (even for the first point). The mirrored control point affects the curve going out of this vertex. - An array of three points, the first being the vertex and the next being the control points (control point for curves coming in and out, respectively).
|
||||
- type: array
|
||||
- default: None
|
||||
|
||||
|
||||
@@ -0,0 +1,93 @@
|
||||
# Polygon
|
||||
|
||||
# polygon
|
||||
|
||||
A closed polygon.
|
||||
|
||||
The polygon is defined by its corner points and is closed automatically.
|
||||
|
||||
## Example
|
||||
|
||||
```typst
|
||||
#polygon(
|
||||
fill: blue.lighten(80%),
|
||||
stroke: blue,
|
||||
(20%, 0pt),
|
||||
(60%, 0pt),
|
||||
(80%, 2cm),
|
||||
(0%, 2cm),
|
||||
)
|
||||
```
|
||||
|
||||
```typst
|
||||
#polygon(
|
||||
fill: none | color | gradient | tiling,
|
||||
fill-rule: str,
|
||||
stroke: none | auto | length | color | gradient | stroke | tiling | dictionary,
|
||||
vertices
|
||||
) -> content
|
||||
```
|
||||
|
||||
## Parameters
|
||||
|
||||
- fill:
|
||||
- description: How to fill the polygon. When setting a fill, the default stroke disappears. To create a rectangle with both fill and stroke, you have to configure both.
|
||||
- type: none | color | gradient | tiling
|
||||
- default: none
|
||||
- fill-rule:
|
||||
- description: The drawing rule used to fill the polygon. See the [curve documentation](/docs/reference/visualize/curve/#parameters-fill-rule) for an example.
|
||||
- type: str
|
||||
- default: "non - zero"
|
||||
- stroke:
|
||||
- description: How to [stroke](/docs/reference/visualize/stroke/) the polygon. Can be set to `none` to disable the stroke or to `auto` for a stroke of `1pt` black if and only if no fill is given.
|
||||
- type: none | auto | length | color | gradient | stroke | tiling | dictionary
|
||||
- default: auto
|
||||
- vertices:
|
||||
- description: The vertices of the polygon. Each point is specified as an array of two [relative lengths](/docs/reference/layout/relative/).
|
||||
- type: array
|
||||
- default: None
|
||||
|
||||
|
||||
## Definitions
|
||||
### polygon.regular
|
||||
|
||||
A regular polygon, defined by its size and number of vertices.
|
||||
|
||||
```typst
|
||||
#polygon.regular(
|
||||
fill: blue.lighten(80%),
|
||||
stroke: blue,
|
||||
size: 30pt,
|
||||
vertices: 3,
|
||||
)
|
||||
```
|
||||
|
||||
```typst
|
||||
#polygon.regular(
|
||||
fill: none | color | gradient | tiling,
|
||||
stroke: none | auto | length | color | gradient | stroke | tiling | dictionary,
|
||||
size: length,
|
||||
vertices: int
|
||||
) -> content
|
||||
```
|
||||
|
||||
#### Parameters
|
||||
|
||||
- fill:
|
||||
- description: How to fill the polygon. See the general [polygon\'s documentation](/docs/reference/visualize/polygon/#parameters-fill) for more details.
|
||||
- type: none | color | gradient | tiling
|
||||
- default: None
|
||||
- stroke:
|
||||
- description: How to stroke the polygon. See the general [polygon\'s documentation](/docs/reference/visualize/polygon/#parameters-stroke) for more details.
|
||||
- type: none | auto | length | color | gradient | stroke | tiling | dictionary
|
||||
- default: None
|
||||
- size:
|
||||
- description: The diameter of the [circumcircle](https://en.wikipedia.org/wiki/Circumcircle) of the regular polygon.
|
||||
- type: length
|
||||
- default: 1em
|
||||
- vertices:
|
||||
- description: The number of vertices in the polygon.
|
||||
- type: int
|
||||
- default: 3
|
||||
|
||||
|
||||
@@ -0,0 +1,68 @@
|
||||
# Rectangle
|
||||
|
||||
# rect
|
||||
|
||||
A rectangle with optional content.
|
||||
|
||||
## Example
|
||||
|
||||
```typst
|
||||
// Without content.
|
||||
#rect(width: 35%, height: 30pt)
|
||||
|
||||
// With content.
|
||||
#rect[
|
||||
Automatically sized \
|
||||
to fit the content.
|
||||
]
|
||||
```
|
||||
|
||||
```typst
|
||||
#rect(
|
||||
width: auto | relative,
|
||||
height: auto | relative | fraction,
|
||||
fill: none | color | gradient | tiling,
|
||||
stroke: none | auto | length | color | gradient | stroke | tiling | dictionary,
|
||||
radius: relative | dictionary,
|
||||
inset: relative | dictionary,
|
||||
outset: relative | dictionary,
|
||||
body
|
||||
) -> content
|
||||
```
|
||||
|
||||
## Parameters
|
||||
|
||||
- width:
|
||||
- description: The rectangle\'s width, relative to its parent container.
|
||||
- type: auto | relative
|
||||
- default: auto
|
||||
- height:
|
||||
- description: The rectangle\'s height, relative to its parent container.
|
||||
- type: auto | relative | fraction
|
||||
- default: auto
|
||||
- fill:
|
||||
- description: How to fill the rectangle. When setting a fill, the default stroke disappears. To create a rectangle with both fill and stroke, you have to configure both. ```typst #rect(fill: blue) ```
|
||||
- type: none | color | gradient | tiling
|
||||
- default: none
|
||||
- stroke:
|
||||
- description: How to stroke the rectangle. This can be: - `none` to disable stroking - `auto` for a stroke of `1pt + black` if and only if no fill is given. - Any kind of [stroke](/docs/reference/visualize/stroke/) - A dictionary describing the stroke for each side individually. The dictionary can contain the following keys in order of precedence: - `top`: The top stroke. - `right`: The right stroke. - `bottom`: The bottom stroke. - `left`: The left stroke. - `x`: The horizontal stroke. - `y`: The vertical stroke. - `rest`: The stroke on all sides except those for which the dictionary explicitly sets a size. All keys are optional; omitted keys will use their previously set value, or the default stroke if never set. ```typst #stack( dir: ltr, spacing: 1fr, rect(stroke: red), rect(stroke: 2pt), rect(stroke: 2pt + red), ) ```
|
||||
- type: none | auto | length | color | gradient | stroke | tiling | dictionary
|
||||
- default: auto
|
||||
- radius:
|
||||
- description: How much to round the rectangle\'s corners, relative to the minimum of the width and height divided by two. This can be: - A relative length for a uniform corner radius. - A dictionary: With a dictionary, the stroke for each side can be set individually. The dictionary can contain the following keys in order of precedence: - `top-left`: The top-left corner radius. - `top-right`: The top-right corner radius. - `bottom-right`: The bottom-right corner radius. - `bottom-left`: The bottom-left corner radius. - `left`: The top-left and bottom-left corner radii. - `top`: The top-left and top-right corner radii. - `right`: The top-right and bottom-right corner radii. - `bottom`: The bottom-left and bottom-right corner radii. - `rest`: The radii for all corners except those for which the dictionary explicitly sets a size. ```typst #set rect(stroke: 4pt) #rect( radius: ( left: 5pt, top-right: 20pt, bottom-right: 10pt, ), stroke: ( left: red, top: yellow, right: green, bottom: blue, ), ) ```
|
||||
- type: relative | dictionary
|
||||
- default: (:)
|
||||
- inset:
|
||||
- description: How much to pad the rectangle\'s content. See the [box\'s documentation](/docs/reference/layout/box/#parameters-inset) for more details.
|
||||
- type: relative | dictionary
|
||||
- default: 0 % + 5pt
|
||||
- outset:
|
||||
- description: How much to expand the rectangle\'s size without affecting the layout. See the [box\'s documentation](/docs/reference/layout/box/#parameters-outset) for more details.
|
||||
- type: relative | dictionary
|
||||
- default: (:)
|
||||
- body:
|
||||
- description: The content to place into the rectangle. When this is omitted, the rectangle takes on a default size of at most `45pt` by `30pt`.
|
||||
- type: none | content
|
||||
- default: none
|
||||
|
||||
|
||||
@@ -0,0 +1,73 @@
|
||||
# Square
|
||||
|
||||
# square
|
||||
|
||||
A square with optional content.
|
||||
|
||||
## Example
|
||||
|
||||
```typst
|
||||
// Without content.
|
||||
#square(size: 40pt)
|
||||
|
||||
// With content.
|
||||
#square[
|
||||
Automatically \
|
||||
sized to fit.
|
||||
]
|
||||
```
|
||||
|
||||
```typst
|
||||
#square(
|
||||
size: auto | length,
|
||||
width: auto | relative,
|
||||
height: auto | relative | fraction,
|
||||
fill: none | color | gradient | tiling,
|
||||
stroke: none | auto | length | color | gradient | stroke | tiling | dictionary,
|
||||
radius: relative | dictionary,
|
||||
inset: relative | dictionary,
|
||||
outset: relative | dictionary,
|
||||
body
|
||||
) -> content
|
||||
```
|
||||
|
||||
## Parameters
|
||||
|
||||
- size:
|
||||
- description: The square\'s side length. This is mutually exclusive with `width` and `height`.
|
||||
- type: auto | length
|
||||
- default: auto
|
||||
- width:
|
||||
- description: The square\'s width. This is mutually exclusive with `size` and `height`. In contrast to `size`, this can be relative to the parent container\'s width.
|
||||
- type: auto | relative
|
||||
- default: auto
|
||||
- height:
|
||||
- description: The square\'s height. This is mutually exclusive with `size` and `width`. In contrast to `size`, this can be relative to the parent container\'s height.
|
||||
- type: auto | relative | fraction
|
||||
- default: auto
|
||||
- fill:
|
||||
- description: How to fill the square. See the [rectangle\'s documentation](/docs/reference/visualize/rect/#parameters-fill) for more details.
|
||||
- type: none | color | gradient | tiling
|
||||
- default: none
|
||||
- stroke:
|
||||
- description: How to stroke the square. See the [rectangle\'s documentation](/docs/reference/visualize/rect/#parameters-stroke) for more details.
|
||||
- type: none | auto | length | color | gradient | stroke | tiling | dictionary
|
||||
- default: auto
|
||||
- radius:
|
||||
- description: How much to round the square\'s corners. See the [rectangle\'s documentation](/docs/reference/visualize/rect/#parameters-radius) for more details.
|
||||
- type: relative | dictionary
|
||||
- default: (:)
|
||||
- inset:
|
||||
- description: How much to pad the square\'s content. See the [box\'s documentation](/docs/reference/layout/box/#parameters-inset) for more details.
|
||||
- type: relative | dictionary
|
||||
- default: 0 % + 5pt
|
||||
- outset:
|
||||
- description: How much to expand the square\'s size without affecting the layout. See the [box\'s documentation](/docs/reference/layout/box/#parameters-outset) for more details.
|
||||
- type: relative | dictionary
|
||||
- default: (:)
|
||||
- body:
|
||||
- description: The content to place into the square. The square expands to fit this content, keeping the 1-1 aspect ratio. When this is omitted, the square takes on a default size of at most `30pt`.
|
||||
- type: none | content
|
||||
- default: none
|
||||
|
||||
|
||||
@@ -0,0 +1,89 @@
|
||||
# Stroke
|
||||
|
||||
Defines how to draw a line.
|
||||
|
||||
A stroke has a _paint_ (a solid color or gradient), a _thickness,_ a line _cap,_ a line _join,_ a _miter limit,_ and a _dash_ pattern. All of these values are optional and have sensible defaults.
|
||||
|
||||
## Example
|
||||
|
||||
```typst
|
||||
#set line(length: 100%)
|
||||
#stack(
|
||||
spacing: 1em,
|
||||
line(stroke: 2pt + red),
|
||||
line(stroke: (paint: blue, thickness: 4pt, cap: "round")),
|
||||
line(stroke: (paint: blue, thickness: 1pt, dash: "dashed")),
|
||||
line(stroke: 2pt + gradient.linear(..color.map.rainbow)),
|
||||
)
|
||||
```
|
||||
|
||||
## Simple strokes
|
||||
|
||||
You can create a simple solid stroke from a color, a thickness, or a combination of the two. Specifically, wherever a stroke is expected you can pass any of the following values:
|
||||
|
||||
- A length specifying the stroke's thickness. The color is inherited, defaulting to black.
|
||||
- A color to use for the stroke. The thickness is inherited, defaulting to `1pt`.
|
||||
- A stroke combined from color and thickness using the `+` operator as in `2pt + red`.
|
||||
|
||||
For full control, you can also provide a [dictionary](/docs/reference/foundations/dictionary/) or a `stroke` object to any function that expects a stroke. The dictionary's keys may include any of the parameters for the constructor function, shown below.
|
||||
|
||||
## Fields
|
||||
|
||||
On a stroke object, you can access any of the fields listed in the constructor function. For example, `(2pt + blue).thickness` is `2pt`. Meanwhile, `stroke(red).cap` is `auto` because it's unspecified. Fields set to `auto` are inherited.
|
||||
|
||||
## Constructor
|
||||
## stroke
|
||||
|
||||
Converts a value to a stroke or constructs a stroke with the given parameters.
|
||||
|
||||
Note that in most cases you do not need to convert values to strokes in order to use them, as they will be converted automatically. However, this constructor can be useful to ensure a value has all the fields of a stroke.
|
||||
|
||||
```typst
|
||||
#let my-func(x) = {
|
||||
x = stroke(x) // Convert to a stroke
|
||||
[Stroke has thickness #x.thickness.]
|
||||
}
|
||||
#my-func(3pt) \
|
||||
#my-func(red) \
|
||||
#my-func(stroke(cap: "round", thickness: 1pt))
|
||||
```
|
||||
|
||||
```typst
|
||||
#stroke(
|
||||
paint,
|
||||
thickness,
|
||||
cap,
|
||||
join,
|
||||
dash,
|
||||
miter-limit
|
||||
) -> stroke
|
||||
```
|
||||
|
||||
### Parameters
|
||||
|
||||
- paint:
|
||||
- description: The color or gradient to use for the stroke. If set to `auto`, the value is inherited, defaulting to `black`.
|
||||
- type: auto | color | gradient | tiling
|
||||
- default: None
|
||||
- thickness:
|
||||
- description: The stroke\'s thickness. If set to `auto`, the value is inherited, defaulting to `1pt`.
|
||||
- type: auto | length
|
||||
- default: None
|
||||
- cap:
|
||||
- description: How the ends of the stroke are rendered. If set to `auto`, the value is inherited, defaulting to `"butt"`.
|
||||
- type: auto | str
|
||||
- default: None
|
||||
- join:
|
||||
- description: How sharp turns are rendered. If set to `auto`, the value is inherited, defaulting to `"miter"`.
|
||||
- type: auto | str
|
||||
- default: None
|
||||
- dash:
|
||||
- description: The dash pattern to use. This can be: - One of the predefined patterns: - `"solid"` or `none` - `"dotted"` - `"densely-dotted"` - `"loosely-dotted"` - `"dashed"` - `"densely-dashed"` - `"loosely-dashed"` - `"dash-dotted"` - `"densely-dash-dotted"` - `"loosely-dash-dotted"` - An [array](/docs/reference/foundations/array/) with alternating lengths for dashes and gaps. You can also use the string `"dot"` for a length equal to the line thickness. - A [dictionary](/docs/reference/foundations/dictionary/) with the keys `array` (same as the array above), and `phase` (of type [length](/docs/reference/layout/length/)), which defines where in the pattern to start drawing. If set to `auto`, the value is inherited, defaulting to `none`. ```typst #set line(length: 100%, stroke: 2pt) #stack( spacing: 1em, line(stroke: (dash: "dashed")), line(stroke: (dash: (10pt, 5pt, "dot", 5pt))), line(stroke: (dash: (array: (10pt, 5pt, "dot", 5pt), phase: 10pt))), ) ```
|
||||
- type: none | auto | str | array | dictionary
|
||||
- default: None
|
||||
- miter-limit:
|
||||
- description: Number at which protruding sharp bends are rendered with a bevel instead or a miter join. The higher the number, the sharper an angle can be before it is bevelled. Only applicable if `join` is `"miter"`. Specifically, the miter limit is the maximum ratio between the corner\'s protrusion length and the stroke\'s thickness. If set to `auto`, the value is inherited, defaulting to `4.0`. ```typst #let items = ( curve.move((15pt, 0pt)), curve.line((0pt, 30pt)), curve.line((30pt, 30pt)), curve.line((10pt, 20pt)), ) #set curve(stroke: 6pt + blue) #stack( dir: ltr, spacing: 1cm, curve(stroke: (miter-limit: 1), ..items), curve(stroke: (miter-limit: 4), ..items), curve(stroke: (miter-limit: 5), ..items), ) ```
|
||||
- type: auto | float
|
||||
- default: None
|
||||
|
||||
|
||||
@@ -0,0 +1,119 @@
|
||||
# Tiling
|
||||
|
||||
A repeating tiling fill.
|
||||
|
||||
Typst supports the most common type of tilings, where a pattern is repeated in a grid-like fashion, covering the entire area of an element that is filled or stroked. The pattern is defined by a tile size and a body defining the content of each cell. You can also add horizontal or vertical spacing between the cells of the tiling.
|
||||
|
||||
## Examples
|
||||
|
||||
```typst
|
||||
#let pat = tiling(size: (30pt, 30pt))[
|
||||
#place(line(start: (0%, 0%), end: (100%, 100%)))
|
||||
#place(line(start: (0%, 100%), end: (100%, 0%)))
|
||||
]
|
||||
|
||||
#rect(fill: pat, width: 100%, height: 60pt, stroke: 1pt)
|
||||
```
|
||||
|
||||
Tilings are also supported on text, but only when setting the [relativeness](/docs/reference/visualize/tiling/#constructor-relative) to either `auto` (the default value) or `"parent"`. To create word-by-word or glyph-by-glyph tilings, you can wrap the words or characters of your text in [boxes](/docs/reference/layout/box/) manually or through a [show rule](/docs/reference/styling/#show-rules).
|
||||
|
||||
```typst
|
||||
#let pat = tiling(
|
||||
size: (30pt, 30pt),
|
||||
relative: "parent",
|
||||
square(
|
||||
size: 30pt,
|
||||
fill: gradient
|
||||
.conic(..color.map.rainbow),
|
||||
)
|
||||
)
|
||||
|
||||
#set text(fill: pat)
|
||||
#lorem(10)
|
||||
```
|
||||
|
||||
You can also space the elements further or closer apart using the [`spacing`](/docs/reference/visualize/tiling/#constructor-spacing) feature of the tiling. If the spacing is lower than the size of the tiling, the tiling will overlap. If it is higher, the tiling will have gaps of the same color as the background of the tiling.
|
||||
|
||||
```typst
|
||||
#let pat = tiling(
|
||||
size: (30pt, 30pt),
|
||||
spacing: (10pt, 10pt),
|
||||
relative: "parent",
|
||||
square(
|
||||
size: 30pt,
|
||||
fill: gradient
|
||||
.conic(..color.map.rainbow),
|
||||
),
|
||||
)
|
||||
|
||||
#rect(
|
||||
width: 100%,
|
||||
height: 60pt,
|
||||
fill: pat,
|
||||
)
|
||||
```
|
||||
|
||||
## Relativeness
|
||||
|
||||
The location of the starting point of the tiling is dependent on the dimensions of a container. This container can either be the shape that it is being painted on, or the closest surrounding container. This is controlled by the `relative` argument of a tiling constructor. By default, tilings are relative to the shape they are being painted on, unless the tiling is applied on text, in which case they are relative to the closest ancestor container.
|
||||
|
||||
Typst determines the ancestor container as follows:
|
||||
|
||||
- For shapes that are placed at the root/top level of the document, the closest ancestor is the page itself.
|
||||
- For other shapes, the ancestor is the innermost [`block`](/docs/reference/layout/block/) or [`box`](/docs/reference/layout/box/) that contains the shape. This includes the boxes and blocks that are implicitly created by show rules and elements. For example, a [`rotate`](/docs/reference/layout/rotate/) will not affect the parent of a gradient, but a [`grid`](/docs/reference/layout/grid/) will.
|
||||
|
||||
## Compatibility
|
||||
|
||||
This type used to be called `pattern`. The name remains as an alias, but is deprecated since Typst 0.13.
|
||||
|
||||
## Constructor
|
||||
## tiling
|
||||
|
||||
Construct a new tiling.
|
||||
|
||||
```typst
|
||||
#let pat = tiling(
|
||||
size: (20pt, 20pt),
|
||||
relative: "parent",
|
||||
place(
|
||||
dx: 5pt,
|
||||
dy: 5pt,
|
||||
rotate(45deg, square(
|
||||
size: 5pt,
|
||||
fill: black,
|
||||
)),
|
||||
),
|
||||
)
|
||||
|
||||
#rect(width: 100%, height: 60pt, fill: pat)
|
||||
```
|
||||
|
||||
```typst
|
||||
#tiling(
|
||||
size: auto | array,
|
||||
spacing: array,
|
||||
relative: auto | str,
|
||||
body
|
||||
) -> tiling
|
||||
```
|
||||
|
||||
### Parameters
|
||||
|
||||
- size:
|
||||
- description: The bounding box of each cell of the tiling.
|
||||
- type: auto | array
|
||||
- default: auto
|
||||
- spacing:
|
||||
- description: The spacing between cells of the tiling.
|
||||
- type: array
|
||||
- default: (0pt, 0pt)
|
||||
- relative:
|
||||
- description: The [relative placement](#relativeness) of the tiling. For an element placed at the root/top level of the document, the parent is the page itself. For other elements, the parent is the innermost block, box, column, grid, or stack that contains the element.
|
||||
- type: auto | str
|
||||
- default: auto
|
||||
- body:
|
||||
- description: The content of each cell of the tiling.
|
||||
- type: content
|
||||
- default: None
|
||||
|
||||
|
||||
Reference in new issue
Block a user