all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* simple elisp animation?
@ 2008-03-27 16:50 someusernamehere
  2008-03-27 17:56 ` Lennart Borgman (gmail)
       [not found] ` <mailman.9507.1206640618.18990.help-gnu-emacs@gnu.org>
  0 siblings, 2 replies; 4+ messages in thread
From: someusernamehere @ 2008-03-27 16:50 UTC (permalink / raw)
  To: help-gnu-emacs

Which is the easiest way for does the following in elisp, I´m trying
to do a kind of simple "animation", I mean e.g. I have first in the
buffer:

     o
   / | \
    / \

how I can transform before in:

 __o__
     |
    / \

and after some more positions


thanks.


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: simple elisp animation?
  2008-03-27 16:50 simple elisp animation? someusernamehere
@ 2008-03-27 17:56 ` Lennart Borgman (gmail)
       [not found] ` <mailman.9507.1206640618.18990.help-gnu-emacs@gnu.org>
  1 sibling, 0 replies; 4+ messages in thread
From: Lennart Borgman (gmail) @ 2008-03-27 17:56 UTC (permalink / raw)
  To: someusernamehere; +Cc: help-gnu-emacs

someusernamehere wrote:
> Which is the easiest way for does the following in elisp, I´m trying
> to do a kind of simple "animation", I mean e.g. I have first in the
> buffer:
> 
>      o
>    / | \
>     / \
> 
> how I can transform before in:
> 
>  __o__
>      |
>     / \
> 
> and after some more positions

Can't you just use run-with-timer and replace the content?




^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: simple elisp animation?
       [not found] ` <mailman.9507.1206640618.18990.help-gnu-emacs@gnu.org>
@ 2008-03-27 18:11   ` someusernamehere
  2008-03-27 20:08     ` Pascal Bourguignon
  0 siblings, 1 reply; 4+ messages in thread
From: someusernamehere @ 2008-03-27 18:11 UTC (permalink / raw)
  To: help-gnu-emacs

On 27 mar, 11:56, "Lennart Borgman (gmail)"
<lennart.borg...@gmail.com> 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)


thanks


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: simple elisp animation?
  2008-03-27 18:11   ` someusernamehere
@ 2008-03-27 20:08     ` Pascal Bourguignon
  0 siblings, 0 replies; 4+ messages in thread
From: Pascal Bourguignon @ 2008-03-27 20:08 UTC (permalink / raw)
  To: help-gnu-emacs

someusernamehere <someusernamehere@gmail.com> writes:

> On 27 mar, 11:56, "Lennart Borgman (gmail)"
> <lennart.borg...@gmail.com> 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:

\f
___
\f
/\_
\f
 __/
\f
 ___
\f
 /\_
\f
  __/
\f
  ___
\f
  /\_
\f
   __/
\f
   ___
\f
   /\_
\f
    __/
\f
    ___
\f
    /\_
\f
     __/



-- 
__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.


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2008-03-27 20:08 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-03-27 16:50 simple elisp animation? someusernamehere
2008-03-27 17:56 ` Lennart Borgman (gmail)
     [not found] ` <mailman.9507.1206640618.18990.help-gnu-emacs@gnu.org>
2008-03-27 18:11   ` someusernamehere
2008-03-27 20:08     ` Pascal Bourguignon

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.