Layer Configuration

Configuration objects are used to configure certain properties of a layer when they are added to a composition. The following property groups are adjustable:

All the configuration objects in a layerConfig are optional, and will be set to sensible defaults if unused. There are two ways to configure a layer; you can either pass a layerConfig object to the add<LayerType> method, or you can use the chainable setter methods on the layer class.

Audio

interface Audio {
  audio?: {
    // number between 0 (muted) and 1 (full volume)
    // defaults to 1
    volume?: number;
  };
}

Position

interface Position {
  position?: {
    // number of degrees to rotate layer clockwise
    // defaults to 0
    angle?: number

    // number of degrees to rotate layer clockwise along the X axis
    // defaults to 0
    angleX?: number

    // number of degrees to rotate layer clockwise along the Y axis
    // defaults to 0
    angleY?: number

    // defaults to false
    isRelative?: boolean

    // point at which transformations originate from. defaults to 'center'
    origin?: string

    // number of pixels from left, or auto-position
    // defaults to 0
    x?: number | 'left' | 'center' | 'right'

    // number of pixels from top, or auto-position
    // defaults to 0
    y?: number | 'top' | 'center' | 'bottom'
  }
}

Size

interface Size {
  size?: {
    // defaults to undefined
    format?: 'fill' | 'fit' | 'stretch'

    // number of pixels,
    // defaults to original media height or composition height
    height?: number

    // ratio of size increase or decrease, 1 is normal
    scale?: number

    // number of pixels,
    // defaults to original media width or composition width
    width?: number
  }
}

Timeline

interface Timeline {
  timeline?: {
    // seconds from the start of the video
    // to start the layer. defaults to 0
    start?: number;
  };
}

Transitions

interface Transitions {
  // defaults to empty array
  transitions?: [
    {
      options: TransitionFadeOptions | TransitionParameterOptions

      type:
        | 'fadeIn'
        | 'fadeOut'
        | 'crossfadeIn'
        | 'crossfadeOut'
        | 'angle'
        | 'angleX'
        | 'angleY'
        | 'scale'
        | 'x'
        | 'y'
    }
  ]
}

interface TransitionFadeOptions {
  duration: number // number of seconds for the transition to complete
}

interface TransitionKenBurnsOptions {
  start: number// time in seconds at which the transition should start
  end: number // time in seconds at which the transition should end
  scale1: number // scale at which to start
  scale2: number // scale at which to end
  x1: number // x position at which to start
  x2: number // x position at which to end
  y1: number // y position at which to start
  y2: number // y position at which to end
}

interface TransitionParameterOptions {
  easing?: // defaults to linear
    | 'easeIn'
    | 'easeInOut'
    | 'easeOut'
    | 'elasticIn'
    | 'elasticInOut'
    | 'elasticOut'
  easingParameter?: // defaults to 1
  time: number // time in seconds at which the parameter should equal the value
  value: number // value of the parameter
}

Trim

interface Trim {
  trim?: {
    // number of seconds from
    // the beginning of layer to trim off
    // defaults to 0
    start?: number;

    // number of seconds that
    // a layer should last
    // defaults to original media duration
    // or composition duration for media without duration
    end?: number;
  };
}