# Animating an image on the foreground of the camera using the Zoom SDK Layers API

**URL:** <https://devforum.zoom.us/t/animating-an-image-on-the-foreground-of-the-camera-using-the-zoom-sdk-layers-api/107441>\
**Category:** Zoom Apps\
**Tags:** api, sdk\
**Created:** [April 8, 2024, 12:42pm UTC](https://devforum.zoom.us/t/animating-an-image-on-the-foreground-of-the-camera-using-the-zoom-sdk-layers-api/107441 "2024-04-08T12:42:55Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![info.mysocial360](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/info.mysocial360/32/57299_2.png) [@info.mysocial360](https://devforum.zoom.us/u/info.mysocial360)\
**Post date:** [April 8, 2024, 12:42pm UTC](https://devforum.zoom.us/t/animating-an-image-on-the-foreground-of-the-camera-using-the-zoom-sdk-layers-api/107441/1 "2024-04-08T12:42:55Z")

</div>

So far drawing sharps and images on the foreground of the camera using the layers api is working. [Docs](https://appssdk.zoom.us/classes/ZoomSdk.ZoomSdk.html)

**What I am doing**  
Getting the **image data** from a canvas element that I am drawing images and shapes to.  
`const imageData = ctx.getImageData(0, 0, 1280, 720);`

Use the zoom sdk to draw the image on the camera foreground.

```auto
const zoomData = await zoomSdk.drawImage({
          x: 0,
          y: 0,
          imageData: imageData,
          zIndex: 3,
});

```

Later on I clear the image data from the camera fore with.  
`await zoomSdk.clearImage({ imageId: imageId });`

This is all working fine, however, when I want to animate the position of the image that is when the problems starts. According the zoom sdk [docs](https://appssdk.zoom.us/classes/ZoomSdk.ZoomSdk.html#drawImage) if i want to move the image i have to clear and redraw. Which is what I am doing the problem is because it is asynchronous the animation is choppy and not smooth.

I am using **requestAnimationFrame** to do the animations if that helps.

So my question is **how can I do an image animation on camera foreground using the Zoom SDK Layers API?**
