help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Graphics in Emacs (was: Unicode box-drawing chars)


From: Oliver Scholz
Subject: Graphics in Emacs (was: Unicode box-drawing chars)
Date: Sat, 14 Sep 2002 09:46:30 +0200
User-agent: Gnus/5.090008 (Oort Gnus v0.08) Emacs/21.2 (i686-pc-linux-gnu)

address@hidden (Kai Großjohann) writes:

> Oliver Scholz <address@hidden> writes:
>
>> * Check for the width as above, but care for the proper alignment by
>>   inserting spaces after the Latin font. (IIRC Emacs allows for spaces
>>   of arbitrary width.)
>
> Maybe it's possible to just draw pixels in Emacs?  If not, that might
> be a useful addition.  Then you ask Emacs about the width in pixels
> of the text and draw some lines for the box.

Well, it is already possible to generate images on the fly. This --
for example -- is from my recent experiments:

(defun egoge-make-xpm-hbar (&optional width height colour)
  (or width (setq width (frame-char-width)))
  (or height (setq height (frame-char-height)))
  (or colour (setq colour (face-attribute 'default :foreground)))
  (find-image `((:type xpm :ascent center
                       :data ,(egoge-make-xpm-hbar-data width height colour)))))


(defun egoge-make-xpm-hbar-data (width height colour)
  (let ((bar-line (truncate (/ height 2)))
        (list nil)
        (count 0))
    (while (< count height)
      (if (= count bar-line)
          (push (make-string width ?o) list)
        (push (make-string width ?\ ) list))
      (setq count (1+ count)))
    (concat "/* XPM */\n"
            "static char *noname[] = {\n"
            (format "\"%d %d 2 1\",\n" width height)
            "/* colors */\n"
            "\"  c None\",\n"
            (format "\"o c %s\",\n" colour)
            "/* pixels */\n"
            "\"" (mapconcat 'identity list "\",\n\"") "\"};")))

[It would be better to use XBM or PBM instead of XPM, but I don't know
the according specs offhand.]

Now `(insert-image (egoge-make-xpm-hbar))' inserts a horizontal
bar XPM-image with the width and height of the default font. This is,
of course, very kludgy. It is somehow strange to create a string that
is supposed to be the equivalent of an XPM-file and then to make an
image from that string. It would be nice if Emacs provided some means
to do something like this immediately. This could help to develop all
kind of fancy GUI stuff.

And while I am dreaming:

A few months ago someone posted a patch in gnu.emacs.sources that
allows to draw pixels immediately on the screen. This would allow
basic vector graphics in Emacs. I'd like to see that included to.

For what would it be useful? I don't know yet. I am pretty sure that
someone would invent something useful or playful, if this feature were
available. I am pretty sure, that I would invent something ... :-)

One thing come to my mind: DrScheme, the editor for PLT Scheme,
provides a nice feature with vector graphics: If you hold the
mouse-pointer over a symbol in the argument-list of a function,
DrScheme draws a line from this symbol to all further occurences in
the function definition. This is supposed to help programming-newbies
to see what happens where with their arguments.

[And Emacs is supposed to be friendly to programming-newbies, too.]

> Maybe something has to be added to the display engine for this to
> work.
[...]

*sigh* To be sure, Emacs is the most wonderful application in the
 world. But there is so much missing, yet.

It is a pity that a general-purpose application is so bad at dealing
with images. ;-)

    -- Oliver

-- 
28 Fructidor an 210 de la Révolution
Liberté, Egalité, Fraternité!


reply via email to

[Prev in Thread] Current Thread [Next in Thread]