Skip to content

Commit

Permalink
feat(web): 🎸 Add getLayerBoundingBox method usage example
Browse files Browse the repository at this point in the history
  • Loading branch information
theashraf committed Oct 25, 2024
1 parent aee0360 commit 5389283
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions .changeset/nervous-trains-dream.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,19 @@ feat(web): 🎸 added `getLayerBoundingBox` method
Basic usage:

```typescript
// Draw a rectangle around the layer 'Layer 1'
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) {
if (boundingBox && context) {
const { x, y, width, height } = boundingBox;
context.strokeRect(x, y, width, height);
}
Expand Down

0 comments on commit 5389283

Please sign in to comment.