A minimal example showing group-level shadow rendering in Konva using a small runtime patch. The shadow is drawn beneath a cached Group, leaving the group content clean.
- Group-level shadow for Konva
Groupvia cached bitmap - Sliders: blur, opacity, offsetX, offsetY
npm inpm run devOpen the app, toggle “Group shadow enabled”, move sliders, and drag/transform the group. The shadow stays beneath the content.
src/konva-patch-group-shadow.ts: runtime patch that hooksKonva.Group.prototype.drawSceneto render the shadow using the group cachesrc/App.tsx: React Konva demo using a cachedGroup, sliders, and aTransformer
- The
Groupis cached (group.cache()), enabling access to its cached scene canvas - On draw, we paint the cached image with canvas shadow styles
- Immediately erase the image portion using
destination-out, leaving only the shadow underneath - The original
drawSceneruns, drawing the group content normally
Shadow props live on the Group:
shadowEnabled,shadowColor,shadowBlur,shadowOpacity,shadowOffset
Cache refresh: called initially and after drag/transform to keep the cache in sync.
MIT