aboutsummaryrefslogtreecommitdiffstats
path: root/lisp/image.el
diff options
context:
space:
mode:
Diffstat (limited to 'lisp/image.el')
-rw-r--r--lisp/image.el36
1 files changed, 28 insertions, 8 deletions
diff --git a/lisp/image.el b/lisp/image.el
index d213c5d6d79..6c15a7d0b96 100644
--- a/lisp/image.el
+++ b/lisp/image.el
@@ -687,6 +687,19 @@ do not check N is within the range of frames present in the image."
687 (plist-put (cdr image) :index n) 687 (plist-put (cdr image) :index n)
688 (force-window-update)) 688 (force-window-update))
689 689
690(defun image-animate-get-speed (image)
691 "Return the speed factor for animating IMAGE."
692 (or (plist-get (cdr image) :speed) 1))
693
694(defun image-animate-set-speed (image value &optional multiply)
695 "Set the speed factor for animating IMAGE to VALUE.
696With optional argument MULTIPLY non-nil, treat VALUE as a
697multiplication factor for the current value."
698 (plist-put (cdr image) :speed
699 (if multiply
700 (* value (image-animate-get-speed image))
701 value)))
702
690;; FIXME? The delay may not be the same for different sub-images, 703;; FIXME? The delay may not be the same for different sub-images,
691;; hence we need to call image-multi-frame-p to return it. 704;; hence we need to call image-multi-frame-p to return it.
692;; But it also returns count, so why do we bother passing that as an 705;; But it also returns count, so why do we bother passing that as an
@@ -700,21 +713,28 @@ TIME-ELAPSED is the total time that has elapsed since
700LIMIT determines when to stop. If t, loop forever. If nil, stop 713LIMIT determines when to stop. If t, loop forever. If nil, stop
701 after displaying the last animation frame. Otherwise, stop 714 after displaying the last animation frame. Otherwise, stop
702 after LIMIT seconds have elapsed. 715 after LIMIT seconds have elapsed.
703The minimum delay between successive frames is `image-minimum-frame-delay'." 716The minimum delay between successive frames is `image-minimum-frame-delay'.
717
718If the image has a non-nil :speed property, it acts as a multiplier
719for the animation speed. A negative value means to animate in reverse."
704 (image-show-frame image n t) 720 (image-show-frame image n t)
705 (setq n (1+ n)) 721 (let* ((speed (image-animate-get-speed image))
706 (let* ((time (float-time)) 722 (time (float-time))
707 (animation (image-multi-frame-p image)) 723 (animation (image-multi-frame-p image))
708 ;; Subtract off the time we took to load the image from the 724 ;; Subtract off the time we took to load the image from the
709 ;; stated delay time. 725 ;; stated delay time.
710 (delay (max (+ (or (cdr animation) image-default-frame-delay) 726 (delay (max (+ (* (or (cdr animation) image-default-frame-delay)
727 (/ 1 (abs speed)))
711 time (- (float-time))) 728 time (- (float-time)))
712 image-minimum-frame-delay)) 729 image-minimum-frame-delay))
713 done) 730 done)
714 (if (>= n count) 731 (setq n (if (< speed 0)
715 (if limit 732 (1- n)
716 (setq n 0) 733 (1+ n)))
717 (setq done t))) 734 (if limit
735 (cond ((>= n count) (setq n 0))
736 ((< n 0) (setq n (1- count))))
737 (and (or (>= n count) (< n 0)) (setq done t)))
718 (setq time-elapsed (+ delay time-elapsed)) 738 (setq time-elapsed (+ delay time-elapsed))
719 (if (numberp limit) 739 (if (numberp limit)
720 (setq done (>= time-elapsed limit))) 740 (setq done (>= time-elapsed limit)))