Function: image-animate
image-animate is a byte-compiled function defined in image.el.gz.
Signature
(image-animate IMAGE &optional INDEX LIMIT POSITION)
Documentation
Start animating IMAGE.
Animation occurs by destructively altering the IMAGE spec list.
With optional INDEX, begin animating from that animation frame. LIMIT specifies how long to animate the image. If omitted or nil, play the animation until the end. If t, loop forever. If a number, play until that number of seconds has elapsed.
If POSITION (which should be buffer position where the image is displayed), stop the animation if the image is no longer displayed.
Probably introduced at or before Emacs version 24.1.
Source Code
;; Defined in /usr/src/emacs/lisp/image.el.gz
(defun image-animate (image &optional index limit position)
"Start animating IMAGE.
Animation occurs by destructively altering the IMAGE spec list.
With optional INDEX, begin animating from that animation frame.
LIMIT specifies how long to animate the image. If omitted or
nil, play the animation until the end. If t, loop forever. If a
number, play until that number of seconds has elapsed.
If POSITION (which should be buffer position where the image is
displayed), stop the animation if the image is no longer
displayed."
(let ((animation (image-multi-frame-p image))
timer)
(when animation
(if (setq timer (image-animate-timer image))
(cancel-timer timer))
(plist-put (cdr image) :animate-buffer (current-buffer))
(plist-put (cdr image) :animate-tardiness 0)
(when position
(plist-put (cdr image) :animate-position
(set-marker (make-marker) position (current-buffer))))
;; Stash the data about the animation here so that we don't
;; trigger image recomputation unnecessarily later.
(plist-put (cdr image) :animate-multi-frame-data animation)
(run-with-timer 0.2 nil #'image-animate-timeout
image (or index 0) (car animation)
0 limit (+ (float-time) 0.2)))))