Node / Canvas · reference
Canvas shadow — every ShadowOptions field
Current Apexify.js 6.0.0 documentation for Canvas shadow — every ShadowOptions field.
Set shadow on CanvasConfig when calling await painter.createCanvas({ … }). Apexify paints a filled silhouette behind your clipped rectangle — offset, softened, and optionally gradient-filled — mimicking a card drop shadow.
Type ShadowOptions is exported from apexify.js / apexify.js/types (common.ts).
Minimal example
SOURCEtypescript
typescript
Field reference (ShadowOptions)
| Field | Type | Default (if omitted) | What it does |
|---|---|---|---|
color | string | "rgba(0,0,0,1)" | Solid fill for the shadow shape before opacity multiplies it. Ignored when gradient is set. |
gradient | gradient | — | Linear / radial / conic gradient fill for the shadow (same gradient discriminated union as backgrounds). Overrides color. |
offsetX, offsetY | number | 0 | Shifts the shadow rectangle from the canvas x/y box (positive offsetY → shadow sits lower). |
blur | number | 20 | Gaussian blur (CSS px) applied only to the shadow pass (blur(…)) — 0 = hard-edged silhouette. |
opacity | number | 0.4 | Multiplies globalAlpha for the shadow fill (0…1 typical). |
borderRadius | number | "circular" | 0 | Corner rounding of the shadow shape itself — match canvas.borderRadius for consistent rounded cards. |
roundedCorners | borderPosition | "all" | Which corners of the shadow path use borderRadius (same vocabulary as canvas.borderPosition — "top-left", "top", comma-separated combos, …). |
borderPosition | borderPosition | — | Deprecated alias for roundedCorners — prefer roundedCorners for new code. |
Behaviour notes
- Paint order: Background stack finishes first; shadow is drawn after backgrounds but before
stroke(paint order). - Clip vs shadow: The visible card uses
canvas.borderRadius. The shadow usesshadow.borderRadius/shadow.roundedCorners— set both when you want the blur to hug rounded corners. - Gradient shadows: Useful for coloured ambient light (
linear/radial/conic— same shapes asgradientBg). - Blur: Large
blurvalues are visually heavier; tune together withopacity.