← 输入框|imagescript.dev|刷新
ImageScript v4.1.0
    Preparing search index...

    ClassAnimationEncoder

    Encodes an animation a frame at a time, without keeping all frames in memory: see Animation.webpEncoder, Animation.gifEncoder and Animation.apngEncoder

    The file is the one an Animation of the frames encodes to, but for unoptimized WebPs with frames WebP can't store as they are (disposed to the previous frame, or disposed with odd offsets): from the first of them on, the frames are the canvas they show (the same animation, blending rounds differently by 1 at most). APNGs keep their frames compressed until the end: their pixel format depends on all of them

    Index
    height: number

    The canvas height

    width: number

    The canvas width

    • Adds the next frame: a Frame (with its duration, offsets and disposal) or an image (a frame of 100 ms by default). The options override the frame's. The pixels are copied right away, the image can change afterwards

      Parameters

      Returns Promise<void>

      TypeError if the frame isn't a Frame or an Image

      RangeError if the duration is negative or more than the format stores

      Error if the encoder is finished

    • Encodes the rest and returns the file. The encoder can't be used afterwards

      Returns Promise<Uint8Array<ArrayBuffer>>

      RangeError if no frame was added

      Error if the encoder is finished already