Outline
.outline() draws a border around the entire canvas edge. It is typically added as the last layer so it sits on top of all content.
Signature
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
width |
int |
required | Border thickness in pixels. Positive integer. |
color |
str |
required | Border color. Hex string ("#RRGGBB" or "#RRGGBBAA"). |
offset |
int |
0 |
Inset distance from the canvas edge in pixels. Non-negative integer. |
opacity |
float |
1.0 |
Layer opacity from 0.0 to 1.0. |
Examples
Basic outline
Inset outline
Semi-transparent outline
Typical usage in a full composition
canvas = (
Canvas(1280, 720)
.background(color="#0F172A")
.text(content="TITLE", size=96, color="#FFFFFF", align="center")
.outline(width=12, color="#22d3ee") # always last
)
Notes
- The outline is drawn inward from the canvas edge by default (
offset=0). - Using a large
offsetwith a thinwidthcan create a floating frame effect. opacitymust be between0.0and1.0.