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

    ClassFrame

    A frame of an Animation: an Image (Frame.image) with a duration, offsets and a disposal mode

    The frame has the methods that change the image's size (resize() including its 'contain' and 'cover' fit modes, scale(), crop(), trim(), rotate(), transform(), dropShadow() and outline()), which move the offsets along so the frame stays in place in the animation; every other change goes to the image (frame.image.blur(2)). The image's own size-changing methods leave the offsets as they are. Offsets can become negative: the parts of a frame outside the animation's canvas aren't encoded

    Index
    • get duration(): number

      The frame's duration in milliseconds (a finite number from 0, else it throws a RangeError). It doesn't have to be a whole number: encoding rounds it, to whole milliseconds for APNG and WebP and, as GIFs store hundredths of a second, to 10 ms for GIF (1.5 ms becomes 0, 5 ms becomes 10). Browsers play GIF frames shorter than 20 ms with 100 ms

      Returns number

    • set duration(duration: number): void

      Sets the duration

      Parameters

      • duration: number

        Milliseconds, a finite number from 0

      Returns void

    • get height(): number

      The frame's height (its image's)

      Returns number

    • get image(): Image

      The frame's pixels. Changing the image changes the frame; the offsets stay as they are

      Returns Image

    • set image(image: Image): void

      Replaces the frame's pixels

      Parameters

      • image: Image

        The new image (used as it is, not copied)

      Returns void

    • get width(): number

      The frame's width (its image's)

      Returns number

    • get xOffset(): number

      The frame's horizontal offset in the animation: an integer, values with a fraction are truncated like image sizes (a value that isn't a finite number throws a RangeError)

      Returns number

    • set xOffset(x: number): void

      Sets the horizontal offset

      Parameters

      • x: number

        The offset in pixels

      Returns void

    • get yOffset(): number

      The frame's vertical offset in the animation: an integer, like Frame.xOffset

      Returns number

    • set yOffset(y: number): void

      Sets the vertical offset

      Parameters

      • y: number

        The offset in pixels

      Returns void

    • Clones the frame: its image (with its pixels and gain map), duration, offsets and disposal mode

      Returns Frame

    • Crops the frame to a region of it, moving the offsets so the remaining pixels stay where they are in the animation. The region is clipped to the frame

      Parameters

      • x: number

        The x offset in the frame (0-based)

      • y: number

        The y offset in the frame (0-based)

      • width: number

        The new width

      • height: number

        The new height

      Returns this

    • Resizes the frame, scaling its offsets along with it (as if the whole animation was resized by the same factor)

      Parameters

      Returns this

    • Resizes the frame, scaling its offsets along with it: to the given width or height (the other side keeps the aspect ratio), or to both

      Parameters

      Returns this

    • Rotates the frame clockwise around its middle, like Image.rotate: when it grows (or shrinks), the offsets move so its middle stays where it is in the animation

      Parameters

      Returns this

    • A short description for debugging, e.g. Frame<64x64x100ms>

      Returns string