-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(web): 🎸 added getLayerBoundingBox method (#377)
* feat(web): 🎸 added getLayerBoundingBox method
- Loading branch information
Showing
3 changed files
with
91 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
--- | ||
'@lottiefiles/dotlottie-web': minor | ||
--- | ||
|
||
feat(web): 🎸 added `getLayerBoundingBox` method | ||
|
||
Basic usage: | ||
|
||
```typescript | ||
const canvas = document.getElementById('dotLottie-canvas'); | ||
|
||
const dotLottie = new DotLottie({ | ||
canvas, | ||
... | ||
}); | ||
|
||
// Draw a rectangle around the layer 'Layer 1' after a frame is renderered | ||
dotLottie.addEventListener('render', () => { | ||
const boundingBox = dotLottie.getLayerBoundingBox('Layer 1'); | ||
const context = canvas.getContext('2d'); | ||
|
||
if (boundingBox && context) { | ||
const { x, y, width, height } = boundingBox; | ||
context.strokeRect(x, y, width, height); | ||
} | ||
}); | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters