> For the complete documentation index, see [llms.txt](https://capsule-video.gitbook.io/cloud/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://capsule-video.gitbook.io/cloud/scripts-1/scripting-basics/transforms-scaling-and-resizing.md).

# Transforms (Scaling, Rotating, and Translating)

The `transform` key affects the rotation, scaling, and translation of a clip's asset. Hypno script provides built-in options for simple fit and fill algorithms, as well as the ability to rotate in common increments.&#x20;

`hypno.transform.fit` scales the longer side of the image to the script dimensions (like css contain) and `hypno.transform.fill` scales the shorter side (like css cover). And, you can add `CW` , `CCW`, and `Flip` to any of these parameters to include a rotation clockwise, counter-clockwise, and flipped, respectively. For example, `transform: hypno.transform.fillCW` fills and rotates the image counter clockwise. Here's what it looks like in the code:

```javascript
// Transform Demo 1

import * as hypno from './stl.js'

const mainTrack = composition.track("main")

hypno.buildTimeline({

    fps: 30,
    resolution: new Vector(960, 1280),
    clips: [
        {
            asset: new Asset("./air-camera-input-1")
            start: 0,
            duration: 120,
            track: mainTrack,
            transform: hypno.transform.fillCW
        },
    ]
})
```

Check out the visual examples below, where the figure on the left shows the input dimensions, and the figure on the right shows the image after the `transform`.

{% tabs %}
{% tab title="fit" %}
![](/files/-M2ZcVOY0jmB8TJ-mAdM)
{% endtab %}

{% tab title="fitFlip" %}
![](/files/-M2ZcaOISaHDclp6s0FI)
{% endtab %}

{% tab title="fitCW" %}
![](/files/-M2Zci1_xM36BsIhZrPR)
{% endtab %}

{% tab title="fitCCW" %}
![](/files/-M2ZcsbUc-ss-dr7gl5K)
{% endtab %}

{% tab title="fill" %}
![](/files/-M2Zd2lYJuk8YHPvXuzU)
{% endtab %}

{% tab title="fillFlip" %}
![](/files/-M2ZdOpnQ1x7_hie_R0b)
{% endtab %}

{% tab title="fillCW" %}
![](/files/-M2ZdgztoFSaj0TKAB2l)
{% endtab %}

{% tab title="fillCCW" %}
![](/files/-M2Zdk_UnQNI8TpZjS-8)
{% endtab %}
{% endtabs %}

You can also use the more advanced option of specifying values manually for the transform, in which case you pass in an object with the `translate`, `scale`, and `rotate` keys. See example below.

```javascript
// Transform Demo 2

import * as hypno from './stl.js'

const mainTrack = composition.track("main")

hypno.buildTimeline({

    fps: 30,
    resolution: new Vector(960, 1280),
    clips: [
        {
            asset: new Asset("./air-camera-input-1")
            start: 0,
            duration: 120,
            track: mainTrack,
            transform: {
                translate: new Vector(0, 1620)
                scale: new Vector(960/1080, 960/1080)
                rotate: -0.5
            }
        },
    ]
})
```
