From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Pascal Bourguignon Newsgroups: gmane.emacs.help Subject: Re: simple elisp animation? Date: Thu, 27 Mar 2008 21:08:24 +0100 Organization: Informatimago Message-ID: <87iqz8q69z.fsf@thalassa.informatimago.com> References: <408f650a-042f-432c-847f-42a8c7d20852@i12g2000prf.googlegroups.com> <1de26e7c-e77c-47e2-b823-5e94fbddb9fb@a23g2000hsc.googlegroups.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1206650475 9096 80.91.229.12 (27 Mar 2008 20:41:15 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 27 Mar 2008 20:41:15 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Thu Mar 27 21:41:46 2008 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1Jeyuv-0002aB-Im for geh-help-gnu-emacs@m.gmane.org; Thu, 27 Mar 2008 21:41:46 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1JeyuK-00023S-0s for geh-help-gnu-emacs@m.gmane.org; Thu, 27 Mar 2008 16:41:08 -0400 Original-Path: shelby.stanford.edu!headwall.stanford.edu!newshub.sdsu.edu!proxad.net!feeder1-2.proxad.net!cleanfeed3-a.proxad.net!nnrp10-2.free.fr!not-for-mail Original-Newsgroups: gnu.emacs.help Face: iVBORw0KGgoAAAANSUhEUgAAADAAAAAwAQMAAABtzGvEAAAABlBMVEUAAAD///+l2Z/dAAAA oElEQVR4nK3OsRHCMAwF0O8YQufUNIQRGIAja9CxSA55AxZgFO4coMgYrEDDQZWPIlNAjwq9 033pbOBPtbXuB6PKNBn5gZkhGa86Z4x2wE67O+06WxGD/HCOGR0deY3f9Ijwwt7rNGNf6Oac l/GuZTF1wFGKiYYHKSFAkjIo1b6sCYS1sVmFhhhahKQssRjRT90ITWUk6vvK3RsPGs+M1RuR mV+hO/VvFAAAAABJRU5ErkJggg== X-Accept-Language: fr, es, en X-Disabled: X-No-Archive: no User-Agent: Gnus/5.1008 (Gnus v5.10.8) Emacs/22.1.50 (gnu/linux) Cancel-Lock: sha1:YThkZDM5NGY0ZmU2Mzc5YTlkMzhhNGZjOWY5NTc4MTEwNDUyYWYxZQ== Original-Lines: 114 Original-NNTP-Posting-Date: 27 Mar 2008 21:08:24 MET Original-NNTP-Posting-Host: 88.180.86.168 Original-X-Trace: 1206648504 news-3.free.fr 1799 88.180.86.168:41573 Original-X-Complaints-To: abuse@proxad.net Original-Xref: shelby.stanford.edu gnu.emacs.help:157383 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:52751 Archived-At: someusernamehere writes: > On 27 mar, 11:56, "Lennart Borgman (gmail)" > wrote: > >> Can't you just use run-with-timer and replace the content? > > > mmmm, but with this I need to wrote the entire content of two (or > more) animation positions, > I have in mind some work with coordinates (which I dont know how in > elisp) (require 'cl) (deftype character () 'fixnum "") ; emacs lisp characters are fixnums. (defun character (object) (etypecase object (character object) (string (aref object 0)))) (defun* set-pixel (x y &optional (color "*")) (goto-char (point-min)) (insert (make-string (forward-line y) (character "\n"))) (beginning-of-line) (let ((width (- (save-excursion (end-of-line) (point)) (point)))) (when (<= width x) (end-of-line) (insert (make-string (- x width -1) (character " ")))) (beginning-of-line) (forward-char x) (delete-char 1) (insert (character color)))) (loop with base = 40 for i from 0 to 80 do (set-pixel i (round (+ base (* 20 (sin (* 2 pi (/ i 80.0)))))) (+ 32 i))) But of course, it would be much much more efficient to erase the old region and insert a new one in block, than doing it pixel by pixel like this. (I mean, character by character of course). For example, you can play movies with: (defun pjb-animate (speed) (interactive "nSpeed: ") (let ((delay (/ 1.0 speed)) (done nil)) (widen) (goto-char (point-min)) (message "Animating...") (while (not done) (widen) (if (search-forward "\f" nil 'at-limit) nil (goto-char (point-max)) (setq done t)) (narrow-to-page) (sit-for delay) (force-mode-line-update t) ) ;;while (message "Done."))) Just draw each pictures, one per page (pictures separated with form-feeds, Control-L, that you can enter with C-q C-l), and M-x pjb-animate RET them. For example: ___ /\_ __/ ___ /\_ __/ ___ /\_ __/ ___ /\_ __/ ___ /\_ __/ -- __Pascal Bourguignon__ http://www.informatimago.com/ CONSUMER NOTICE: Because of the "uncertainty principle," it is impossible for the consumer to simultaneously know both the precise location and velocity of this product.