• Stars
    star
    464
  • Rank 94,450 (Top 2 %)
  • Language
    Emacs Lisp
  • License
    GNU General Publi...
  • Created about 3 years ago
  • Updated 8 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Embedded drawing tool for Emacs

Emacs Easy Draw

Emacs Easy Draw is a drawing tool that runs inside Emacs.

./screenshot/edraw-screenshot.gif

Requirements

  • Emacs 27.2
  • Image support
  • SVG support
  • gzip and gunzip(or zlib support)
  • libxml support

Screenshots

https://github.com/misohena/el-easydraw/wiki/Screenshots

Use In Org-Mode - edraw-org.el

Config

(with-eval-after-load 'org
  (require 'edraw-org)
  (edraw-org-setup-default))
;; When using the org-export-in-background option (when using the
;; asynchronous export function), the following settings are
;; required. This is because Emacs started in a separate process does
;; not load org.el but only ox.el.
(with-eval-after-load "ox"
  (require 'edraw-org)
  (edraw-org-setup-exporter))

Usage

To start drawing, type [​[edraw:]] and type C-c C-o on the link.

Draw something and type C-c C-c and the data will be saved in the buffer.

Link Notation

[​[edraw:file=./example.edraw.svg]​]

[​[edraw:data=<base64data>​]]

[​[*Example][edraw:file=./example.edraw.svg]​]

[​[*Example][edraw:data=<base64data>]​]

Inline Images

To toggle the inline display mode, type M-x edraw-org-link-image-mode

Edit Image

To edit the image, do one of the following on the link:

  • M-x edraw-org-edit-link
  • C-c C-o
  • Right click on image (The right-click menu also provides some other useful functions for links)

Export as HTML

Customization Variables:

edraw-org-export-html-data-tag
HTML tag used to export data links. (svg or img)
edraw-org-export-html-file-tag
HTML tag used to export file links. (svg or img)
edraw-org-export-html-use-viewbox
Add viewBox= attribute to svg root elements when SVG export.

Link Properties:

html-tag
HTML tag used to export the link. (svg or img)

Example:

[[edraw:html-tag=img;data=<base64data>]]
    

Edit a Single Edraw File - edraw-mode.el

(autoload 'edraw-mode "edraw-mode")
(add-to-list 'auto-mode-alist '("\\.edraw\\.svg$" . edraw-mode))

NOTE: Setup later than other modes for .svg such as image-mode.

Emacs Easy Draw can only handle a small subset of the SVG specification, but the files it outputs can be viewed in a browser or other software that can handle SVG.

Key bindings

Most of the key bindings are displayed in menus and help echoes.

The key bindings that are not displayed are as follows.

left, up, right, downMove selected objects (S-<dir>:10px, C-u <dir>:Numerical input)
M-left, M-up, M-right, M-downDuplicate selected objects and move (M-S-<dir>:10px, C-u M-<dir>:Numerical input)
Right-click on shapes, anchor points, background, shape picker, or edraw linksShow context menu
(Select Tool) C-down-mouse-1Add/Remove clicked shape to selection list
(Select Tool) M-drag-mouse-1Duplicate dragged shape
(Path Tool) C-u down-mouse-1Ignore existing points (Avoid connecting or moving existing points)
S-drag-mouse-145 degree unit movement or square specification
Middle-dragScroll
C-wheel-up, C-wheel-downZoom
(In Property Editor) Middle-clickClose window
(In Shape Picker) Middle-clickClose window

Emacs Lisp

The following code is an example of inserting an editor into a buffer from Emacs Lisp.

(require 'edraw)

(progn
  (insert " ")
  (let ((editor (edraw-editor
                 ;; Make an overlay that covers " "
                 ;; 'evaporate means automatic deletion
                 :overlay (let ((overlay (make-overlay (1- (point)) (point))))
                            (overlay-put overlay 'evaporate t)
                            overlay)
                 ;; Initial SVG
                 :svg (let ((initial-svg (svg-create 400 300)))
                        (dom-append-child
                         initial-svg
                         (dom-node 'g (list (cons 'id "edraw-body")) ;; g#edraw-body is the edit target area
                                   (dom-node 'rect (list (cons 'x "100")
                                                         (cons 'y "100")
                                                         (cons 'width "200")
                                                         (cons 'height "100")
                                                         (cons 'fill "blue")))))
                        initial-svg)
                 ;; Function called when saving
                 :document-writer (lambda (svg &rest _)
                                    (pop-to-buffer "*svg output*")
                                    (erase-buffer)
                                    (edraw-svg-print
                                     svg nil 'edraw-svg-print-attr-filter 0))
                 ;; Add one item to the main menu
                 :menu-filter (lambda (menu-type items &rest _)
                                (pcase menu-type
                                  ('main-menu
                                   (append
                                    items
                                    `(((edraw-msg "Close") (lambda (editor) (edraw-close editor))))))
                                  (_ items))))))
    ;; Initialize editor
    (edraw-initialize editor)
    ;; Add key binding
    (overlay-put (edraw-overlay editor)
                 'keymap
                 (let ((original-keymap (overlay-get (edraw-overlay editor) 'keymap))
                       (km (make-sparse-keymap)))
                   (set-keymap-parent km original-keymap)
                   (define-key km (kbd "C-c C-c") (lambda () (interactive) (edraw-close (edraw-editor-at))))
                   km))))

Color Picker

edraw-color-picker.el contains a color picker library and some commands.

Show color picker in minibuffer:

  • (edraw-color-picker-read-color)

Insert the selected color into the buffer:

  • (edraw-color-picker-insert-color)
  • (edraw-color-picker-replace-color-at-point)

A function that opens a color picker near the point:

  • edraw-color-picker-open-near-point

A function that displays a color picker using an overlay:

  • edraw-color-picker-overlay

The core class of the color picker:

  • edraw-color-picker

./screenshot/color-picker-minibuffer.png

./screenshot/color-picker-inline.png

More Repositories

1

phscroll

Enable partial horizontal scroll in Emacs
Emacs Lisp
85
star
2

el-igo

Emacs Go Game(SGF) Editor
Emacs Lisp
49
star
3

gcal

Google Calendar Utilities for Emacs
Emacs Lisp
12
star
4

org-inline-image-fix

A collection of fixes related to the image display feature in org-mode
Emacs Lisp
12
star
5

org-cmenu

Context Sensitive Menu for Emacs Org Mode
Emacs Lisp
10
star
6

trayrun

Execute windows application under task tray
C++
7
star
7

el-jma

Emacs Interface for Japan Meteorological Agency Data
Emacs Lisp
7
star
8

dired-details-r

Show file details on the right side of the filename in Emacs Dired mode
Emacs Lisp
6
star
9

dired-details-s

Hide dired details separately
Emacs Lisp
4
star
10

ob-html

Org Babel Functions for HTML Code Blocks
Emacs Lisp
4
star
11

git-encwrapper

git wrapper adjustment character encoding.
C
4
star
12

js_calendar

大まかな予定を書き込めるJavaScriptカレンダー(予定表)
JavaScript
3
star
13

my-location

Emacs Lisp code that finds where you were in the past from GPX files.
Emacs Lisp
3
star
14

js_sokoban

JavaScriptとcanvas要素で実装した倉庫番みたいなゲーム
JavaScript
3
star
15

drawstars

星空を描きます
C++
3
star
16

org-geolink

Adds geo location link type to org-mode.
Emacs Lisp
3
star
17

innosetup_template

My Inno Setup Template
C
2
star
18

aush

Console Audio Player
C++
2
star
19

js_galaxysim

JavaScript重力多体シミュレータ(2D)
JavaScript
2
star
20

simple_wix_template

My WiX Toolset Installer Template
Shell
2
star
21

moonrise-el

Moonrise/Moonset Calculation for Emacs
Emacs Lisp
2
star
22

js_pegsolitaire

JavaScript Peg Solitaire Puzzle Game
JavaScript
2
star
23

my-magit-speedup-for-windows

My setup files for Magit on MS-Windows.
Emacs Lisp
2
star
24

js_lifegame

Conway's Game of Life JavaScript Implementation
JavaScript
1
star
25

js_piano

JavaScript HTML5 Audio Piano
JavaScript
1
star
26

piclist

画像リストビューア
C++
1
star
27

el-winsearch

Search for files using Windows Search from Emacs
Emacs Lisp
1
star
28

js_1keyupdown

JavaScript
1
star
29

simple_msi_bootstrapper

Simple Windows Installer setup.exe.
C++
1
star
30

adoquery

Windows ADO Query Command
C++
1
star
31

js_skigame

JavaScript Motion Sensor Ski Game
JavaScript
1
star
32

js_deviceorientation

JavaScript DeviceOrientation Event Viewer
1
star
33

js_fonteditor

JavaScript Freehand Font Editor
JavaScript
1
star
34

org-newtab-link

Open org-mode links exported as HTML in a new tab.
Emacs Lisp
1
star
35

js_igo

JavaScript Go Game Board
JavaScript
1
star
36

js_csstransformutils

convertPointFromPageToNode implementation / CSS Transform properties parser / 4x4 Matrix functions
JavaScript
1
star