SVG effects in GNU Emacs

Emacs is quite a capable SVG renderer - thanks to librsvg. You can render SVG filters (blur and shadow) and gradients (linear and radial) in Emacs buffer to create attractive UI as you like it. These are defined in variable image-svg-defs which can be reused using SVG fill attribute (fill:"url(#grad1)").

The tree structure is created using speedbar. Speedbar uses ezimage to create the icons from images. In Text UI, icons are turned off. You can also turn it off by setting ezimage-use-images to nil.

If you are maintaining your SVG icons as a sprite sheet, you can use <use/> tag to easily include icons. You can also look at SVG widget option for automated widget generation.

 

;;  image-svg-icon assigns a default icon class to tthe image which can be suitably styled
(insert-image (image-svg-icon '("bi file-x") 100 100 ".icon{stroke:red}"))
 
;; Example using CSS style definition
(insert-image (image-svg-icon '("bi file-x") 100 100 ".icon1{stroke:red}" "icon1"))
 
 

Note: Emacs caches images against image-spec. Use image-flush to clear cache selectively.

Code:
https://gitlab.com/atamariya/emacs/-/blob/dev/src/image.c
https://gitlab.com/atamariya/emacs/-/blob/dev/lisp/image.el
https://gitlab.com/atamariya/emacs/-/blob/dev/lisp/ezimage.el
https://gitlab.com/atamariya/emacs/-/blob/dev/lisp/speedbar.el
https://gitlab.com/atamariya/emacs/-/blob/dev/lisp/cedet/semantic/sb.el
 






Comments

Popular posts from this blog

GNU Emacs as a Comic Book Reader

Mozilla Readability in GNU Emacs

Data Visualization with GNU Emacs