Rect
A filled or stroked rectangle in a layer.
Attributes
Section titled “Attributes”| Attribute | Type | Default | Description |
|---|---|---|---|
x |
signed pt | — | X of the left edge (or offset from anchor) |
y |
signed pt | — | Y of the top edge (or offset from anchor) |
width |
pt | — | Required. Width |
height |
pt | — | Required. Height |
anchor |
string | — | Reference point: when set, x and y are offsets, and the rectangle’s matching point is placed there |
radius |
pt | — | Corner radius |
fill |
color or gradient:name |
— | Fill: a color, or a gradient that spans the rectangle |
stroke |
color | — | Stroke color |
stroke-width |
pt | — | Stroke width |
stroke-dash |
string | — | Dash pattern: "4 2" |
shadow |
string | — | A hard-edged shadow under the rectangle: "x y color", with an optional opacity after the color. See Shadow |
Either anchor or both x and y must be provided. To fade a rectangle, put it in a layer with opacity.
Full-page tinted background (underlay)
Section titled “Full-page tinted background (underlay)”A layer before the layout is painted under it.
<layer page="each" opacity="0.4"> <rect x="0pt" y="0pt" width="612pt" height="792pt" fill="#f0f4ff"/></layer>L.layer({ page: 'each', opacity: '0.4' }, [ L.rect({ x: '0pt', y: '0pt', width: '612pt', height: '792pt', fill: '#f0f4ff' }),])L.layer(LayerAttr(page='each', opacity='0.4'), [ L.rect(RectAttr(x='0pt', y='0pt', width='612pt', height='792pt', fill='#f0f4ff'))])L::layer(new LayerAttr(page: 'each', opacity: '0.4'), [ L::rect(new RectAttr(x: '0pt', y: '0pt', width: '612pt', height: '792pt', fill: '#f0f4ff')),])L.Layer(new() { Page = "each", Opacity = "0.4" }, [ L.Rect(new() { X = "0pt", Y = "0pt", Width = "612pt", Height = "792pt", Fill = "#f0f4ff" }),])Inset border (stroke only)
Section titled “Inset border (stroke only)”A rectangle with no fill is drawn as an outline. The stroke is centred on the edge, so half of it falls outside the rectangle.
<layer page="each"> <!-- inset border 20pt from each edge on letter size --> <rect x="20pt" y="20pt" width="572pt" height="752pt" stroke="#cccccc" stroke-width="1pt"/></layer>L.layer({ page: 'each' }, [ L.rect({ x: '20pt', y: '20pt', width: '572pt', height: '752pt', stroke: '#cccccc', strokeWidth: '1pt' }),])L.layer(LayerAttr(page='each'), [ L.rect(RectAttr(x='20pt', y='20pt', width='572pt', height='752pt', stroke='#cccccc', stroke_width='1pt'))])L::layer(new LayerAttr(page: 'each'), [ L::rect(new RectAttr(x: '20pt', y: '20pt', width: '572pt', height: '752pt', stroke: '#cccccc', strokeWidth: '1pt')),])L.Layer(new() { Page = "each" }, [ L.Rect(new() { X = "20pt", Y = "20pt", Width = "572pt", Height = "752pt", Stroke = "#cccccc", StrokeWidth = "1pt" }),])Bar along the top edge
Section titled “Bar along the top edge”anchor places a rectangle against the page, whatever its size.
<layer page="each"> <rect anchor="top-left" width="612pt" height="8pt" fill="#1763cf"/></layer>L.layer({ page: 'each' }, [ L.rect({ anchor: 'top-left', width: '612pt', height: '8pt', fill: '#1763cf' }),])L.layer(LayerAttr(page='each'), [ L.rect(RectAttr(anchor='top-left', width='612pt', height='8pt', fill='#1763cf'))])L::layer(new LayerAttr(page: 'each'), [ L::rect(new RectAttr(anchor: 'top-left', width: '612pt', height: '8pt', fill: '#1763cf')),])L.Layer(new() { Page = "each" }, [ L.Rect(new() { Anchor = "top-left", Width = "612pt", Height = "8pt", Fill = "#1763cf" }),])Rounded highlight box
Section titled “Rounded highlight box”<rect x="40pt" y="100pt" width="200pt" height="60pt" fill="#fff8e1" stroke="#f9a825" stroke-width="1pt" radius="4pt"/>L.rect({ x: '40pt', y: '100pt', width: '200pt', height: '60pt', fill: '#fff8e1', stroke: '#f9a825', strokeWidth: '1pt', radius: '4pt' })L.rect(RectAttr(x='40pt', y='100pt', width='200pt', height='60pt', fill='#fff8e1', stroke='#f9a825', stroke_width='1pt', radius='4pt'))L::rect(new RectAttr(x: '40pt', y: '100pt', width: '200pt', height: '60pt', fill: '#fff8e1', stroke: '#f9a825', strokeWidth: '1pt', radius: '4pt'))L.Rect(new() { X = "40pt", Y = "100pt", Width = "200pt", Height = "60pt", Fill = "#fff8e1", Stroke = "#f9a825", StrokeWidth = "1pt", Radius = "4pt" })